diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dce188f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +.swp diff --git a/index.html b/index.html index 0a07d59..43af134 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 deleted file mode 100644 index f3569dc..0000000 --- a/scripts/jquery.parallax-1.1.3.js +++ /dev/null @@ -1,69 +0,0 @@ -/* -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/ - -Dual licensed under the MIT and GPL licenses: -http://www.opensource.org/licenses/mit-license.php -http://www.gnu.org/licenses/gpl.html -*/ - -(function( $ ){ - var $window = $(window); - var windowHeight = $window.height(); - - $window.resize(function () { - 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; - }); - - 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(); - - $this.each(function(){ - var $element = $(this); - var top = $element.offset().top; - var height = getHeight($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"); - }); - } - - $window.bind('scroll', update).resize(update); - update(); - }; -})(jQuery); diff --git a/scripts/jquery.parallax.js b/scripts/jquery.parallax.js new file mode 100644 index 0000000..1b9de43 --- /dev/null +++ b/scripts/jquery.parallax.js @@ -0,0 +1,191 @@ +/* +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) { + define(['jquery'], factory); + } else { + factory(jQuery, window); + } +})(function($, undefined){ + 'use strict'; + + var Pub, + Parallax, + guid, + parseArgs, + $window = $(window), + scrollTop = $window.scrollTop(), + windowHeight = $window.height(); + + $window.on('resize', function(){ + windowHeight = $window.height(); + Pub.notify(); + }); + + $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]; + }, + + each: function(func) { + $.each(subscribers, function(k,v) { + func.apply(v); + }); + }, + + count: function() { + var size = 0, + key; + + for(key in subscribers) { + if(subscribers.hasOwnProperty(key)) size++; + } + + return size; + }, + + remove_all: function() { + this.each(function(){ this.destroy(); }); + }, + + notify: function() { + scrollTop = $window.scrollTop(); + this.each(function(){ this.check(scrollTop); }); + } + }; + })(); + + Parallax = function(jqo, options){ + this.options = options; + this.originalScrollTop = 0; + this.ypos = 0; + this.started = false; + this.$el = jqo; + this.guid = guid(); + this.refresh(); + + Pub.subscribe(this.guid, this); + }; + + + Parallax.prototype = { + _onScreen: function() { + return !(this.top + this.height < scrollTop || this.top > scrollTop + 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; + }, + + start: function(scrollTop) { + this.originalScrollTop = scrollTop || window.scrollTop(); + this.ypos = parseInt( this.$el.css('backgroundPosition').split(" ")[1] ) || 0; + + $window.on('scroll.parallax' + this.guid, $.proxy(this.update, this) ); + this.started = true; + }, + + stop: function() { + $window.off('scroll.parallax' + this.guid, $.proxy(this.update, this) ); + this.started = false; + }, + + check: function(scrollTop) { + if( this._onScreen() ) { + if( !this.started ) + this.start(scrollTop); + } else { + if( this.started ) { + this.stop(); + } + } + }, + + update: function() { + this.$el.css('backgroundPosition', this.options.xpos + " " + (this.ypos + Math.round((this.originalScrollTop - scrollTop) * this.options.speed)) + "px"); + }, + + destroy: function() { + Pub.remove(this.guid); + this.$el.removeData('parallax'); + this.$el.css('backgroundPosition', ''); + } + }; + + $.fn.parallax = function(options) { + var args = $.makeArray(arguments), + after = args.slice(1); + + return this.each(function() { + var instance, + $el = $(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) ); + } + + }); + }; + + $.Parallax = { + destroy_all: function() { + Pub.remove_all(); + }, + + count: function() { + return Pub.count(); + } + }; + +}); + + + + 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 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; }