From 0110712fe7a64abf51cd345d6d33ce081c67c43c Mon Sep 17 00:00:00 2001 From: Gabriel Fernandes Lopes Guaitolini Date: Thu, 15 Oct 2015 00:07:26 -0300 Subject: [PATCH 1/3] Option for default horizontal position! $('.parallax').scrolly({bgParallax: true, horizontalPos: '100%'}); --- jquery.scrolly.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.scrolly.js b/jquery.scrolly.js index f6523a1..ee22809 100644 --- a/jquery.scrolly.js +++ b/jquery.scrolly.js @@ -70,7 +70,7 @@ if(this.bgStart){ position = position + this.bgStart; } if(this.options.bgParallax === true) { - this.$element.css({backgroundPosition: '50% '+position+'px'}); + this.$element.css({backgroundPosition: (this.options.horizontalPos || '50%') + ' ' + position+'px'}); } else { this.$element.css({top: position}); } From 8ad03bbd26e76dfbc0252cc938a2beee86699342 Mon Sep 17 00:00:00 2001 From: Gabriel Fernandes Lopes Guaitolini Date: Thu, 15 Oct 2015 00:24:19 -0300 Subject: [PATCH 2/3] Scroll event and page refresh Using jquery scroll event (so it starts only when it really scrolled) and adjusting image on page refresh (before, we need to scroll something to adjust the initial position of the image) --- jquery.scrolly.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/jquery.scrolly.js b/jquery.scrolly.js index ee22809..69861f4 100644 --- a/jquery.scrolly.js +++ b/jquery.scrolly.js @@ -40,16 +40,11 @@ this.velocity = this.$element.attr('data-velocity'); this.bgStart = parseInt(this.$element.attr('data-fit'), 10); - $(document).scroll(function(){ + $(document).bind('scroll', function(){ self.didScroll = true; + self.scrolly(); }); - - setInterval(function() { - if (self.didScroll) { - self.didScroll = false; - self.scrolly(); - } - }, 10); + self.scrolly(); }; Plugin.prototype.scrolly = function() { From ba9160da8c3a40064bb0efa5b8b95fc44bbfc23f Mon Sep 17 00:00:00 2001 From: Gabriel Fernandes Lopes Guaitolini Date: Thu, 15 Oct 2015 10:29:48 -0300 Subject: [PATCH 3/3] Bind to On Bind will be deprecated, so use on instead. --- jquery.scrolly.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.scrolly.js b/jquery.scrolly.js index 69861f4..b4a45a0 100644 --- a/jquery.scrolly.js +++ b/jquery.scrolly.js @@ -40,7 +40,7 @@ this.velocity = this.$element.attr('data-velocity'); this.bgStart = parseInt(this.$element.attr('data-fit'), 10); - $(document).bind('scroll', function(){ + $(document).on('scroll', function(){ self.didScroll = true; self.scrolly(); });