Skip to content
This repository was archived by the owner on Jul 27, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scripts/jquery.parallax-1.1.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);

Expand All @@ -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");
});
}

Expand Down