From 1c2d6117d9a1f009138ce95046696702ee647698 Mon Sep 17 00:00:00 2001 From: Kynareth62 Date: Sun, 19 Oct 2014 18:19:49 +0200 Subject: [PATCH] Add "alterHeightPosition" parameter I have added a simple "alterHeightPosition" paramater controle with precision the default position of the background image. Exemple without parallax(**"50%", 0.8**): http://puu.sh/ciEgw/f585fa5b17.jpg (white margin bellow) Exemple with my modification and parallax(**"50%", 0.8, 100**); The third parameter add +100px to the top of the background. http://puu.sh/ciEv9/186ea60e53.jpg We can use this new option for controle the position with precision and adjust the render :) --- scripts/jquery.parallax-1.1.3.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index f3569dc..d42821e 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -19,7 +19,7 @@ http://www.gnu.org/licenses/gpl.html windowHeight = $window.height(); }); - $.fn.parallax = function(xpos, speedFactor, outerHeight) { + $.fn.parallax = function(xpos, speedFactor, alterHeightPosition, outerHeight) { var $this = $(this); var getHeight; var firstTop; @@ -59,7 +59,14 @@ http://www.gnu.org/licenses/gpl.html return; } - $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); + if(typeof alternHeightPosition != 'undefined') { + calc = firstTop - pos + alternHeightPosition; + } + else { + calc = firstTop - pos; + } + + $this.css('backgroundPosition', xpos + " " + Math.round((calc) * speedFactor) + "px"); }); }