Skip to content

Commit 5440c8d

Browse files
author
George Lee
committed
Fixes bug with styleBank
1 parent df0703c commit 5440c8d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

scrollReveal.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
window.scrollReveal = (function (window) {
2828

2929
'use strict';
30+
31+
// generator (increments) for the next scroll-reveal-id
32+
var nextId = 1;
3033

3134
function scrollReveal(options) {
3235

3336
this.docElem = window.document.documentElement;
3437
this.options = this.extend(this.defaults, options);
35-
this.styleBank = [];
38+
this.styleBank = {};
3639

3740
if (this.options.init == true) this.init();
3841
}
@@ -72,8 +75,13 @@ window.scrollReveal = (function (window) {
7275
this.elems.forEach(function (el, i) {
7376

7477
// 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');
7785
}
7886

7987
self.update(el);
@@ -205,7 +213,7 @@ window.scrollReveal = (function (window) {
205213
update: function (el) {
206214

207215
var css = this.genCSS(el);
208-
var style = this.styleBank[el];
216+
var style = this.styleBank[el.getAttribute("data-scroll-reveal-id")];
209217

210218
if (style != null) style += ";"; else style = "";
211219

0 commit comments

Comments
 (0)