From ae633dbe96cf7dc6a24d1d8a85f87d8afd1f9377 Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Thu, 22 Aug 2013 09:46:07 -0600 Subject: [PATCH 01/16] Making plugin AMD compatible --- scripts/jquery.parallax-1.1.3.js | 105 ++++++++++++++++--------------- 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index f3569dc..08ff9ac 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -11,59 +11,66 @@ http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html */ -(function( $ ){ - var $window = $(window); - var windowHeight = $window.height(); +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(jQuery); + } +}(function ($) { - $window.resize(function () { - windowHeight = $window.height(); - }); + var $window = $(window); + var windowHeight = $window.height(); - $.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; - }); + $window.resize(function () { + windowHeight = $window.height(); + }); - if (outerHeight) { - getHeight = function(jqo) { - return jqo.outerHeight(true); - }; - } else { - getHeight = function(jqo) { - return jqo.height(); - }; - } - - // setup defaults if arguments aren't specified - if (arguments.length < 1 || xpos === null) xpos = "50%"; - if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; - if (arguments.length < 3 || outerHeight === null) outerHeight = true; - - // function to be called whenever the window is scrolled or resized - function update(){ - var pos = $window.scrollTop(); + $.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(){ - var $element = $(this); - var top = $element.offset().top; - var height = getHeight($element); + if (outerHeight) { + getHeight = function(jqo) { + return jqo.outerHeight(true); + }; + } else { + getHeight = function(jqo) { + return jqo.height(); + }; + } + + // setup defaults if arguments aren't specified + if (arguments.length < 1 || xpos === null) xpos = "50%"; + if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; + if (arguments.length < 3 || outerHeight === null) outerHeight = true; + + // function to be called whenever the window is scrolled or resized + function update(){ + var pos = $window.scrollTop(); - // Check if totally above or totally below viewport - if (top + height < pos || top > pos + windowHeight) { - return; - } + $this.each(function(){ + var $element = $(this); + var top = $element.offset().top; + var height = getHeight($element); - $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); - }); - } + // Check if totally above or totally below viewport + if (top + height < pos || top > pos + windowHeight) { + return; + } - $window.bind('scroll', update).resize(update); - update(); - }; -})(jQuery); + $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); + }); + } + + $window.bind('scroll', update).resize(update); + update(); + }; +})); From 2d36e008a841e45d1a84623df73a70c1c367b815 Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Fri, 23 Aug 2013 11:31:42 -0600 Subject: [PATCH 02/16] Checks for initial background position on elements and animates from that spot --- scripts/jquery.parallax-1.1.3.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index 08ff9ac..f2c391c 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -27,15 +27,9 @@ 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; - }); + var getHeight, + firstTop, + $this = this; if (outerHeight) { getHeight = function(jqo) { @@ -47,6 +41,13 @@ http://www.gnu.org/licenses/gpl.html }; } + firstTop = function(jqo) { + if( typeof jqo.data('firstTop') === 'undefined') + jqo.data( 'firstTop', parseInt( jqo.css('backgroundPosition').split(" ")[1] ) ); + + return jqo.data('firstTop') + } + // setup defaults if arguments aren't specified if (arguments.length < 1 || xpos === null) xpos = "50%"; if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; @@ -60,13 +61,14 @@ http://www.gnu.org/licenses/gpl.html var $element = $(this); var top = $element.offset().top; var height = getHeight($element); - + var ypos = firstTop($element); + // Check if totally above or totally below viewport if (top + height < pos || top > pos + windowHeight) { return; } - $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); + $element.css('backgroundPosition', xpos + " " + (ypos + Math.round((top - (pos + windowHeight)) * speedFactor)) + "px"); }); } @@ -74,3 +76,4 @@ http://www.gnu.org/licenses/gpl.html update(); }; })); + From ee2d0176a6829f08fbcdbebb28279507695688dc Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Sat, 24 Aug 2013 10:54:36 -0600 Subject: [PATCH 03/16] Adding gitignore, removing DS_Store --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 2 ++ 2 files changed, 2 insertions(+) delete mode 100644 .DS_Store create mode 100644 .gitignore diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Sat, 24 Aug 2013 10:58:57 -0600 Subject: [PATCH 04/16] Moves shoe background lower, to emphasis effect --- style.css | 268 +++++++++++++++++++++++++++--------------------------- 1 file changed, 134 insertions(+), 134 deletions(-) diff --git a/style.css b/style.css index 3c5d8dd..2923425 100755 --- a/style.css +++ b/style.css @@ -1,136 +1,136 @@ -/* -Plugin: jQuery Parallax -Version 1.1.3 +/* +Plugin: jQuery Parallax +Version 1.1.3 Author: Ian Lunn -Twitter: @IanLunn -Author URL: http://www.ianlunn.co.uk/ -Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/ - -License: http://creativecommons.org/licenses/by-sa/3.0/ (Attribution Share Alike). Please attribute work to Ian Lunn simply by leaving these comments in the source code or if you'd prefer, place a link on your website to http://www.ianlunn.co.uk/. -*/ - -@charset "utf-8"; -/* CSS Document */ - -body{ - margin: 0; - min-width: 980px; - padding: 0; -} - -p{ - margin: 0 0 20px 0; -} - -p, ul{ - font-family:"Proxima Nova Light", 'Helvetica Neue', Arial, Helvetica, sans-serif; - font-size-adjust:0.488; - font-weight:200; - font-style:normal; -} - -img{ - border: 0; -} - -h1, #pixels{ - font-family:"Museo 900", Verdana, serif; - font-size-adjust:0.40; - font-weight:700; - font-style:normal; -} - -h2{ - font-family:"Beau Sans Pro Book", Verdana, sans-serif; - font-size-adjust:0.531; - font-weight:500; - font-style:normal; -} - -#header h1, #pixels{ - color: #48941A; -} - -.float-left{ - float: left; - margin: 0 0 0 20px; -} - -.float-right{ - float: right; - margin: 0 20px 0 0; -} - -.center{ - font-size: 2.5em; - padding: 80px 0 0 0; - text-align: center; -} - -#nav{ - list-style: none; - position: fixed; - right: 20px; -} - -#nav li{ - margin: 0 0 15px 0; -} - -#header, #intro, #second{ - width: 100%; -} - -#intro{ - background:url(images/firstBG.jpg) 50% 0 no-repeat fixed; - color: white; - height: 600px; - margin: 0 auto; - padding: 0; -} - -#second{ - background: url(images/secondBG.jpg) 50% 0 no-repeat fixed; - color: white; - height: 1300px; - margin: 0 auto; - overflow: hidden; - padding: 0; -} - -#second .bg{ - background: url(images/trainers.png) 50% 0 no-repeat fixed; - height: 1300px; - margin: 0 auto; - padding: 0; - position: absolute; - width: 900px; - z-index: 200; -} - -#third{ - background: url(images/thirdBG.jpg) 50% 0 no-repeat fixed; - color: white; - height: 650px; - padding: 100px 0 0 0; -} - -#fifth{ - background: #ccc; - height: 400px; - margin: 0 auto; - padding: 40px 0 0 0; -} - -.story{ - margin: 0 auto; - min-width: 980px; - overflow: auto; - width: 980px; -} - -.story .float-left, .story .float-right{ - padding: 100px 0 0 0; - position: relative; - width: 350px; +Twitter: @IanLunn +Author URL: http://www.ianlunn.co.uk/ +Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/ + +License: http://creativecommons.org/licenses/by-sa/3.0/ (Attribution Share Alike). Please attribute work to Ian Lunn simply by leaving these comments in the source code or if you'd prefer, place a link on your website to http://www.ianlunn.co.uk/. +*/ + +@charset "utf-8"; +/* CSS Document */ + +body{ + margin: 0; + min-width: 980px; + padding: 0; +} + +p{ + margin: 0 0 20px 0; +} + +p, ul{ + font-family:"Proxima Nova Light", 'Helvetica Neue', Arial, Helvetica, sans-serif; + font-size-adjust:0.488; + font-weight:200; + font-style:normal; +} + +img{ + border: 0; +} + +h1, #pixels{ + font-family:"Museo 900", Verdana, serif; + font-size-adjust:0.40; + font-weight:700; + font-style:normal; +} + +h2{ + font-family:"Beau Sans Pro Book", Verdana, sans-serif; + font-size-adjust:0.531; + font-weight:500; + font-style:normal; +} + +#header h1, #pixels{ + color: #48941A; +} + +.float-left{ + float: left; + margin: 0 0 0 20px; +} + +.float-right{ + float: right; + margin: 0 20px 0 0; +} + +.center{ + font-size: 2.5em; + padding: 80px 0 0 0; + text-align: center; +} + +#nav{ + list-style: none; + position: fixed; + right: 20px; +} + +#nav li{ + margin: 0 0 15px 0; +} + +#header, #intro, #second{ + width: 100%; +} + +#intro{ + background:url(images/firstBG.jpg) 50% 0 no-repeat fixed; + color: white; + height: 600px; + margin: 0 auto; + padding: 0; +} + +#second{ + background: url(images/secondBG.jpg) 50% 0 no-repeat fixed; + color: white; + height: 1300px; + margin: 0 auto; + overflow: hidden; + padding: 0; +} + +#second .bg{ + background: url(images/trainers.png) 50% 500px no-repeat fixed; + height: 1300px; + margin: 0 auto; + padding: 0; + position: absolute; + width: 900px; + z-index: 200; +} + +#third{ + background: url(images/thirdBG.jpg) 50% 0 no-repeat fixed; + color: white; + height: 650px; + padding: 100px 0 0 0; +} + +#fifth{ + background: #ccc; + height: 400px; + margin: 0 auto; + padding: 40px 0 0 0; +} + +.story{ + margin: 0 auto; + min-width: 980px; + overflow: auto; + width: 980px; +} + +.story .float-left, .story .float-right{ + padding: 100px 0 0 0; + position: relative; + width: 350px; } From 8e1d3c7e596f1b0b82605fbb8b45a93d1b1eadfb Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Sat, 24 Aug 2013 11:00:22 -0600 Subject: [PATCH 05/16] Return jQuery object to allow chaining --- scripts/jquery.parallax-1.1.3.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index f2c391c..28a0a86 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -74,6 +74,8 @@ http://www.gnu.org/licenses/gpl.html $window.bind('scroll', update).resize(update); update(); + + return this; }; })); From 556dd39a5c1a49f9fc28d61dba6738fe4515daf4 Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Fri, 30 Aug 2013 10:22:14 -0600 Subject: [PATCH 06/16] Complete rewrite --- index.html | 163 ++++++++++----------- scripts/jquery.localscroll-1.2.7-min.js | 9 -- scripts/jquery.parallax-1.1.3.js | 181 +++++++++++++++--------- scripts/jquery.scrollTo-1.4.2-min.js | 11 -- 4 files changed, 189 insertions(+), 175 deletions(-) delete mode 100755 scripts/jquery.localscroll-1.2.7-min.js delete mode 100755 scripts/jquery.scrollTo-1.4.2-min.js diff --git a/index.html b/index.html index 0a07d59..cb18b0e 100755 --- a/index.html +++ b/index.html @@ -1,90 +1,75 @@ - + - - -jQuery Parallax Plugin Demo - - - - - - - - - - - -
-
-
-

(Almost) Static Background

-

This section has a background that moves slightly slower than the user scrolls. This is achieved by changing the top position of the background for every pixel the page is scrolled.

-
-
-
- -
-
-
-

Multiple Backgrounds

-

The multiple backgrounds applied to this section are moved in a similar way to the first section -- every time the user scrolls down the page by a pixel, the positions of the backgrounds are changed.

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nibh erat, sagittis sit amet congue at, aliquam eu libero. Integer molestie, turpis vel ultrices facilisis, nisi mauris sollicitudin mauris, volutpat elementum enim urna eget odio. Donec egestas aliquet facilisis. Nunc eu nunc eget neque ornare fringilla. Nam vel sodales lectus. Nulla in pellentesque eros. Donec ultricies, enim vitae varius cursus, risus mauris iaculis neque, euismod sollicitudin metus erat vitae sapien. Sed pulvinar.

-
-
- -
- -
-
-
-

What Happens When JavaScript is Disabled?

-

The user gets a slap! Actually, all that jQuery does is moves the backgrounds relative to the position of the scrollbar. Without it, the backgrounds simply stay put and the user would never know they are missing out on the awesome! CSS2 does a good enough job to still make the effect look cool.

-
-
-
- -
-
-

Check out my new plugin Sequence.js for parallax effects and a whole lot more!

- -

Ian Lunn

- - -

This demo is based on the Nikebetterworld.com website.

- -

Credits

-

This plugin makes use of some scripts and images made by others:

- -
-
- - + + +jQuery Parallax Plugin Demo + + + + + + + + +
+
+
+

(Almost) Static Background

+

This section has a background that moves slightly slower than the user scrolls. This is achieved by changing the top position of the background for every pixel the page is scrolled.

+
+
+
+ +
+
+
+

Multiple Backgrounds

+

The multiple backgrounds applied to this section are moved in a similar way to the first section -- every time the user scrolls down the page by a pixel, the positions of the backgrounds are changed.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nibh erat, sagittis sit amet congue at, aliquam eu libero. Integer molestie, turpis vel ultrices facilisis, nisi mauris sollicitudin mauris, volutpat elementum enim urna eget odio. Donec egestas aliquet facilisis. Nunc eu nunc eget neque ornare fringilla. Nam vel sodales lectus. Nulla in pellentesque eros. Donec ultricies, enim vitae varius cursus, risus mauris iaculis neque, euismod sollicitudin metus erat vitae sapien. Sed pulvinar.

+
+
+ +
+ +
+
+
+

What Happens When JavaScript is Disabled?

+

The user gets a slap! Actually, all that jQuery does is moves the backgrounds relative to the position of the scrollbar. Without it, the backgrounds simply stay put and the user would never know they are missing out on the awesome! CSS2 does a good enough job to still make the effect look cool.

+
+
+
+ +
+
+

Check out my new plugin Sequence.js for parallax effects and a whole lot more!

+ +

Ian Lunn

+ + +

This demo is based on the Nikebetterworld.com website.

+ +

Credits

+

This plugin makes use of some scripts and images made by others:

+ +
+
+ + diff --git a/scripts/jquery.localscroll-1.2.7-min.js b/scripts/jquery.localscroll-1.2.7-min.js deleted file mode 100755 index 3f8d64c..0000000 --- a/scripts/jquery.localscroll-1.2.7-min.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * jQuery.LocalScroll - Animated scrolling navigation, using anchors. - * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Dual licensed under MIT and GPL. - * Date: 3/11/2009 - * @author Ariel Flesler - * @version 1.2.7 - **/ -;(function($){var l=location.href.replace(/#.*/,'');var g=$.localScroll=function(a){$('body').localScroll(a)};g.defaults={duration:1e3,axis:'y',event:'click',stop:true,target:window,reset:true};g.hash=function(a){if(location.hash){a=$.extend({},g.defaults,a);a.hash=false;if(a.reset){var e=a.duration;delete a.duration;$(a.target).scrollTo(0,a);a.duration=e}i(0,location,a)}};$.fn.localScroll=function(b){b=$.extend({},g.defaults,b);return b.lazy?this.bind(b.event,function(a){var e=$([a.target,a.target.parentNode]).filter(d)[0];if(e)i(a,e,b)}):this.find('a,area').filter(d).bind(b.event,function(a){i(a,this,b)}).end().end();function d(){return!!this.href&&!!this.hash&&this.href.replace(this.hash,'')==l&&(!b.filter||$(this).is(b.filter))}};function i(a,e,b){var d=e.hash.slice(1),f=document.getElementById(d)||document.getElementsByName(d)[0];if(!f)return;if(a)a.preventDefault();var h=$(b.target);if(b.lock&&h.is(':animated')||b.onBefore&&b.onBefore.call(b,a,f,h)===false)return;if(b.stop)h.stop(true);if(b.hash){var j=f.id==d?'id':'name',k=$(' ').attr(j,d).css({position:'absolute',top:$(window).scrollTop(),left:$(window).scrollLeft()});f[j]='';$('body').prepend(k);location=e.hash;k.remove();f[j]=d}h.scrollTo(f,b).trigger('notify.serialScroll',[f])}})(jQuery); \ No newline at end of file diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-1.1.3.js index 28a0a86..cd46c5a 100644 --- a/scripts/jquery.parallax-1.1.3.js +++ b/scripts/jquery.parallax-1.1.3.js @@ -1,81 +1,130 @@ /* -Plugin: jQuery Parallax -Version 1.1.3 -Author: Ian Lunn -Twitter: @IanLunn -Author URL: http://www.ianlunn.co.uk/ -Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/ +Plugin: jQuery Simple Parallax +Version 0.1 +Author: Jason Hummel +Twitter: @jhummel +Author URL: http://www.wearechalk.com/ +Plugin URL: http://www.github.com/madebychalk/jQuery-Parallax Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html + +Inspired by jQuery Prallax by Ian Lunn +https://github.com/IanLunn/jQuery-Parallax */ -(function (factory) { - if (typeof define === 'function' && define.amd) { +(function(factory) { + if(typeof define === 'function' && define.amd) { define(['jquery'], factory); } else { - factory(jQuery); + factory(jQuery, window); } -}(function ($) { - - var $window = $(window); - var windowHeight = $window.height(); - - $window.resize(function () { - windowHeight = $window.height(); - }); - - $.fn.parallax = function(xpos, speedFactor, outerHeight) { - var getHeight, - firstTop, - $this = this; - - if (outerHeight) { - getHeight = function(jqo) { - return jqo.outerHeight(true); - }; - } else { - getHeight = function(jqo) { - return jqo.height(); - }; - } - - firstTop = function(jqo) { - if( typeof jqo.data('firstTop') === 'undefined') - jqo.data( 'firstTop', parseInt( jqo.css('backgroundPosition').split(" ")[1] ) ); +})(function($, undefined){ + 'use strict'; + + var Pub, + Parallax, + guid, + $window = $(window), + scrollTop = $window.scrollTop(), + windowHeight = $window.height(); + + $window.on('resize', function(){ windowHeight = $window.height(); }); + $window.on('scroll', function(){ Pub.notify(); }); + + guid = function() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); + return v.toString(16); + }); + }; + + Pub = (function(){ + var subscribers = {}; + + return { + subscribe: function(id, obj){ + subscribers[id] = obj; + }, + + remove: function(id){ + delete subscribers[id]; + }, + + notify: function() { + scrollTop = $window.scrollTop(); + $.each(subscribers, function(k,v){ + v.update(); + }); + } + }; + })(); + + Parallax = function(jqo, options){ + this.options = options; + this.$el = jqo; + this.ypos = parseInt( jqo.css('backgroundPosition').split(" ")[1] ); + this.guid = guid(); + this.refresh(); + + Pub.subscribe(this.guid, this); + }; + - return jqo.data('firstTop') + Parallax.prototype = { + _onScreen: function() { + return !(this.top + this.height < this.pos || this.top > this.pos + windowHeight) + }, + + _getHeight: function() { + return (this.options.outerHeight) ? + this.$el.outerHeight(true) : + this.$el.height(); + }, + + refresh: function() { + this.height = this._getHeight(); + this.top = this.$el.offset().top; + }, + + update: function() { + if( this._onScreen() ) + this.$el.css('backgroundPosition', this.options.xpos + " " + (this.ypos + Math.round((this.top - (scrollTop + windowHeight)) * this.options.speed)) + "px"); + }, + + destroy: function() { + Pub.remove(this.guid); } + }; + + $.fn.parallax = function(options) { + var args = $.makeArray(arguments), + after = args.slice(1); + + return this.each(function() { + var instance, + $el = $(this); - // setup defaults if arguments aren't specified - if (arguments.length < 1 || xpos === null) xpos = "50%"; - if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; - if (arguments.length < 3 || outerHeight === null) outerHeight = true; - - // function to be called whenever the window is scrolled or resized - function update(){ - var pos = $window.scrollTop(); - - $this.each(function(){ - var $element = $(this); - var top = $element.offset().top; - var height = getHeight($element); - var ypos = firstTop($element); - - // Check if totally above or totally below viewport - if (top + height < pos || top > pos + windowHeight) { - return; - } - - $element.css('backgroundPosition', xpos + " " + (ypos + Math.round((top - (pos + windowHeight)) * speedFactor)) + "px"); - }); - } - - $window.bind('scroll', update).resize(update); - update(); - - return this; + instance = $el.data('parallax'); + + if(instance) { + instance[args[0]].apply(instance, after); + } else { + options = $.extend({ + xpos: '50%', + speed: 0.25, + outerHeight: true + }, options); + + $el.data( 'parallax', new Parallax($el, options) ); + } + + }); }; -})); + +}); + + + diff --git a/scripts/jquery.scrollTo-1.4.2-min.js b/scripts/jquery.scrollTo-1.4.2-min.js deleted file mode 100755 index 73a3341..0000000 --- a/scripts/jquery.scrollTo-1.4.2-min.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * jQuery.ScrollTo - Easy element scrolling using jQuery. - * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com - * Dual licensed under MIT and GPL. - * Date: 5/25/2009 - * @author Ariel Flesler - * @version 1.4.2 - * - * http://flesler.blogspot.com/2007/10/jqueryscrollto.html - */ -;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery); \ No newline at end of file From 795ab2bd4fb55ca8d5fc58142b82faa1d9496a07 Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Sat, 31 Aug 2013 09:22:09 -0600 Subject: [PATCH 07/16] Moving to new version number --- scripts/{jquery.parallax-1.1.3.js => jquery.parallax-0.1.0.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{jquery.parallax-1.1.3.js => jquery.parallax-0.1.0.js} (100%) diff --git a/scripts/jquery.parallax-1.1.3.js b/scripts/jquery.parallax-0.1.0.js similarity index 100% rename from scripts/jquery.parallax-1.1.3.js rename to scripts/jquery.parallax-0.1.0.js From 28ecab91800f5f50e7ecab591b4e986be01af469 Mon Sep 17 00:00:00 2001 From: Jason Hummel Date: Sat, 31 Aug 2013 09:47:19 -0600 Subject: [PATCH 08/16] Adding ability to destroy all plugins --- index.html | 2 +- scripts/jquery.parallax-0.1.0.js | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index cb18b0e..86be9ce 100755 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ jQuery Parallax Plugin Demo - + - +