From ac1b8c9592ddc1be3a668541447a0df5a1d4c7cc Mon Sep 17 00:00:00 2001 From: Kynareth62 Date: Sun, 19 Oct 2014 18:54:26 +0200 Subject: [PATCH] Update jquery.parallax-1.1.3.js Rename parameter and change position. New JS (load before body element) for auto-load all parallax elements: $(document).ready(function(){ $('.ab-parallax').each(function() { xpos = $(this).attr('parallax-xpos'); ypos = $(this).attr('parallax-ypos'); speed = $(this).attr('parallax-speed'); $(this).parallax(xpos, ypos, speed); }); }) And new usage in html :
Please update documentation if you approve my work :) --- scripts/jquery.parallax-1.1.3.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index f3569dc..10bf0da 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -19,7 +19,9 @@ http://www.gnu.org/licenses/gpl.html windowHeight = $window.height(); }); - $.fn.parallax = function(xpos, speedFactor, outerHeight) { + $.fn.parallax = function(xpos, ypos, speedFactor, outerHeight) { + + var $this = $(this); var getHeight; var firstTop; @@ -59,7 +61,14 @@ http://www.gnu.org/licenses/gpl.html return; } - $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); + if(typeof ypos != 'undefined') { + calc = firstTop - pos + ypos; + } + else { + calc = firstTop - pos; + } + + $this.css('backgroundPosition', xpos + " " + Math.round((calc) * speedFactor) + "px"); }); }