File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 27
27
window . scrollReveal = ( function ( window ) {
28
28
29
29
'use strict' ;
30
+
31
+ // generator (increments) for the next scroll-reveal-id
32
+ var nextId = 1 ;
30
33
31
34
function scrollReveal ( options ) {
32
35
33
36
this . docElem = window . document . documentElement ;
34
37
this . options = this . extend ( this . defaults , options ) ;
35
- this . styleBank = [ ] ;
38
+ this . styleBank = { } ;
36
39
37
40
if ( this . options . init == true ) this . init ( ) ;
38
41
}
@@ -72,8 +75,13 @@ window.scrollReveal = (function (window) {
72
75
this . elems . forEach ( function ( el , i ) {
73
76
74
77
// Capture original style attribute
75
- if ( ! self . styleBank [ el ] ) {
76
- self . styleBank [ el ] = el . getAttribute ( 'style' ) ;
78
+ var id = el . getAttribute ( "data-scroll-reveal-id" ) ;
79
+ if ( ! id ) {
80
+ id = nextId ++ ;
81
+ el . setAttribute ( "data-scroll-reveal-id" , id ) ;
82
+ }
83
+ if ( ! self . styleBank [ id ] ) {
84
+ self . styleBank [ id ] = el . getAttribute ( 'style' ) ;
77
85
}
78
86
79
87
self . update ( el ) ;
@@ -205,7 +213,7 @@ window.scrollReveal = (function (window) {
205
213
update : function ( el ) {
206
214
207
215
var css = this . genCSS ( el ) ;
208
- var style = this . styleBank [ el ] ;
216
+ var style = this . styleBank [ el . getAttribute ( "data-scroll-reveal-id" ) ] ;
209
217
210
218
if ( style != null ) style += ";" ; else style = "" ;
211
219
You can’t perform that action at this time.
0 commit comments