diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index f3569dc..0a06b62 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -22,12 +22,12 @@ http://www.gnu.org/licenses/gpl.html $.fn.parallax = function(xpos, speedFactor, outerHeight) { var $this = $(this); var getHeight; - var firstTop; var paddingTop = 0; //get the starting position of each element to have parallax applied to it - $this.each(function(){ - firstTop = $this.offset().top; + $this.each(function(i,e){ + $element = $(e); + $element.data('firstTop', $element.offset().top); }); if (outerHeight) { @@ -49,8 +49,8 @@ http://www.gnu.org/licenses/gpl.html function update(){ var pos = $window.scrollTop(); - $this.each(function(){ - var $element = $(this); + $this.each(function(i,e){ + var $element = $(e); var top = $element.offset().top; var height = getHeight($element); @@ -59,7 +59,7 @@ http://www.gnu.org/licenses/gpl.html return; } - $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); + $element.css('backgroundPosition', xpos + " " + Math.round(( $element.data('firstTop') - pos) * speedFactor) + "px"); }); }