/*! stellar.js v0.6.2 | copyright 2014, mark dalgleish | http://markdalgleish.com/projects/stellar.js | http://markdalgleish.mit-license.org */ !function(a,b,c,d){function e(b,c){this.element=b,this.options=a.extend({},g,c),this._defaults=g,this._name=f,this.init()}var f="stellar",g={scrollproperty:"scroll",positionproperty:"position",horizontalscrolling:!0,verticalscrolling:!0,horizontaloffset:0,verticaloffset:0,responsive:!1,parallaxbackgrounds:!0,parallaxelements:!0,hidedistantelements:!0,hideelement:function(a){a.hide()},showelement:function(a){a.show()}},h={scroll:{getleft:function(a){return a.scrollleft()},setleft:function(a,b){a.scrollleft(b)},gettop:function(a){return a.scrolltop()},settop:function(a,b){a.scrolltop(b)}},position:{getleft:function(a){return-1*parseint(a.css("left"),10)},gettop:function(a){return-1*parseint(a.css("top"),10)}},margin:{getleft:function(a){return-1*parseint(a.css("margin-left"),10)},gettop:function(a){return-1*parseint(a.css("margin-top"),10)}},transform:{getleft:function(a){var b=getcomputedstyle(a[0])[k];return"none"!==b?-1*parseint(b.match(/(-?[0-9]+)/g)[4],10):0},gettop:function(a){var b=getcomputedstyle(a[0])[k];return"none"!==b?-1*parseint(b.match(/(-?[0-9]+)/g)[5],10):0}}},i={position:{setleft:function(a,b){a.css("left",b)},settop:function(a,b){a.css("top",b)}},transform:{setposition:function(a,b,c,d,e){a[0].style[k]="translate3d("+(b-c)+"px, "+(d-e)+"px, 0)"}}},j=function(){var b,c=/^(moz|webkit|khtml|o|ms|icab)(?=[a-z])/,d=a("script")[0].style,e="";for(b in d)if(c.test(b)){e=b.match(c)[0];break}return"webkitopacity"in d&&(e="webkit"),"khtmlopacity"in d&&(e="khtml"),function(a){return e+(e.length>0?a.charat(0).touppercase()+a.slice(1):a)}}(),k=j("transform"),l=a("
",{style:"background:#fff"}).css("background-position-x")!==d,m=l?function(a,b,c){a.css({"background-position-x":b,"background-position-y":c})}:function(a,b,c){a.css("background-position",b+" "+c)},n=l?function(a){return[a.css("background-position-x"),a.css("background-position-y")]}:function(a){return a.css("background-position").split(" ")},o=b.requestanimationframe||b.webkitrequestanimationframe||b.mozrequestanimationframe||b.orequestanimationframe||b.msrequestanimationframe||function(a){settimeout(a,1e3/60)};e.prototype={init:function(){this.options.name=f+"_"+math.floor(1e9*math.random()),this._defineelements(),this._definegetters(),this._definesetters(),this._handlewindowloadandresize(),this._detectviewport(),this.refresh({firstload:!0}),"scroll"===this.options.scrollproperty?this._handlescrollevent():this._startanimationloop()},_defineelements:function(){this.element===c.body&&(this.element=b),this.$scrollelement=a(this.element),this.$element=this.element===b?a("body"):this.$scrollelement,this.$viewportelement=this.options.viewportelement!==d?a(this.options.viewportelement):this.$scrollelement[0]===b||"scroll"===this.options.scrollproperty?this.$scrollelement:this.$scrollelement.parent()},_definegetters:function(){var a=this,b=h[a.options.scrollproperty];this._getscrollleft=function(){return b.getleft(a.$scrollelement)},this._getscrolltop=function(){return b.gettop(a.$scrollelement)}},_definesetters:function(){var b=this,c=h[b.options.scrollproperty],d=i[b.options.positionproperty],e=c.setleft,f=c.settop;this._setscrollleft="function"==typeof e?function(a){e(b.$scrollelement,a)}:a.noop,this._setscrolltop="function"==typeof f?function(a){f(b.$scrollelement,a)}:a.noop,this._setposition=d.setposition||function(a,c,e,f,g){b.options.horizontalscrolling&&d.setleft(a,c,e),b.options.verticalscrolling&&d.settop(a,f,g)}},_handlewindowloadandresize:function(){var c=this,d=a(b);c.options.responsive&&d.bind("load."+this.name,function(){c.refresh()}),d.bind("resize."+this.name,function(){c._detectviewport(),c.options.responsive&&c.refresh()})},refresh:function(c){var d=this,e=d._getscrollleft(),f=d._getscrolltop();c&&c.firstload||this._reset(),this._setscrollleft(0),this._setscrolltop(0),this._setoffsets(),this._findparticles(),this._findbackgrounds(),c&&c.firstload&&/webkit/.test(navigator.useragent)&&a(b).load(function(){var a=d._getscrollleft(),b=d._getscrolltop();d._setscrollleft(a+1),d._setscrolltop(b+1),d._setscrollleft(a),d._setscrolltop(b)}),this._setscrollleft(e),this._setscrolltop(f)},_detectviewport:function(){var a=this.$viewportelement.offset(),b=null!==a&&a!==d;this.viewportwidth=this.$viewportelement.width(),this.viewportheight=this.$viewportelement.height(),this.viewportoffsettop=b?a.top:0,this.viewportoffsetleft=b?a.left:0},_findparticles:function(){{var b=this;this._getscrollleft(),this._getscrolltop()}if(this.particles!==d)for(var c=this.particles.length-1;c>=0;c--)this.particles[c].$element.data("stellar-elementisactive",d);this.particles=[],this.options.parallaxelements&&this.$element.find("[data-stellar-ratio]").each(function(){var c,e,f,g,h,i,j,k,l,m=a(this),n=0,o=0,p=0,q=0;if(m.data("stellar-elementisactive")){if(m.data("stellar-elementisactive")!==this)return}else m.data("stellar-elementisactive",this);b.options.showelement(m),m.data("stellar-startingleft")?(m.css("left",m.data("stellar-startingleft")),m.css("top",m.data("stellar-startingtop"))):(m.data("stellar-startingleft",m.css("left")),m.data("stellar-startingtop",m.css("top"))),f=m.position().left,g=m.position().top,h="auto"===m.css("margin-left")?0:parseint(m.css("margin-left"),10),i="auto"===m.css("margin-top")?0:parseint(m.css("margin-top"),10),k=m.offset().left-h,l=m.offset().top-i,m.parents().each(function(){var b=a(this);return b.data("stellar-offset-parent")===!0?(n=p,o=q,j=b,!1):(p+=b.position().left,void(q+=b.position().top))}),c=m.data("stellar-horizontal-offset")!==d?m.data("stellar-horizontal-offset"):j!==d&&j.data("stellar-horizontal-offset")!==d?j.data("stellar-horizontal-offset"):b.horizontaloffset,e=m.data("stellar-vertical-offset")!==d?m.data("stellar-vertical-offset"):j!==d&&j.data("stellar-vertical-offset")!==d?j.data("stellar-vertical-offset"):b.verticaloffset,b.particles.push({$element:m,$offsetparent:j,isfixed:"fixed"===m.css("position"),horizontaloffset:c,verticaloffset:e,startingpositionleft:f,startingpositiontop:g,startingoffsetleft:k,startingoffsettop:l,parentoffsetleft:n,parentoffsettop:o,stellarratio:m.data("stellar-ratio")!==d?m.data("stellar-ratio"):1,width:m.outerwidth(!0),height:m.outerheight(!0),ishidden:!1})})},_findbackgrounds:function(){var b,c=this,e=this._getscrollleft(),f=this._getscrolltop();this.backgrounds=[],this.options.parallaxbackgrounds&&(b=this.$element.find("[data-stellar-background-ratio]"),this.$element.data("stellar-background-ratio")&&(b=b.add(this.$element)),b.each(function(){var b,g,h,i,j,k,l,o=a(this),p=n(o),q=0,r=0,s=0,t=0;if(o.data("stellar-backgroundisactive")){if(o.data("stellar-backgroundisactive")!==this)return}else o.data("stellar-backgroundisactive",this);o.data("stellar-backgroundstartingleft")?m(o,o.data("stellar-backgroundstartingleft"),o.data("stellar-backgroundstartingtop")):(o.data("stellar-backgroundstartingleft",p[0]),o.data("stellar-backgroundstartingtop",p[1])),h="auto"===o.css("margin-left")?0:parseint(o.css("margin-left"),10),i="auto"===o.css("margin-top")?0:parseint(o.css("margin-top"),10),j=o.offset().left-h-e,k=o.offset().top-i-f,o.parents().each(function(){var b=a(this);return b.data("stellar-offset-parent")===!0?(q=s,r=t,l=b,!1):(s+=b.position().left,void(t+=b.position().top))}),b=o.data("stellar-horizontal-offset")!==d?o.data("stellar-horizontal-offset"):l!==d&&l.data("stellar-horizontal-offset")!==d?l.data("stellar-horizontal-offset"):c.horizontaloffset,g=o.data("stellar-vertical-offset")!==d?o.data("stellar-vertical-offset"):l!==d&&l.data("stellar-vertical-offset")!==d?l.data("stellar-vertical-offset"):c.verticaloffset,c.backgrounds.push({$element:o,$offsetparent:l,isfixed:"fixed"===o.css("background-attachment"),horizontaloffset:b,verticaloffset:g,startingvalueleft:p[0],startingvaluetop:p[1],startingbackgroundpositionleft:isnan(parseint(p[0],10))?0:parseint(p[0],10),startingbackgroundpositiontop:isnan(parseint(p[1],10))?0:parseint(p[1],10),startingpositionleft:o.position().left,startingpositiontop:o.position().top,startingoffsetleft:j,startingoffsettop:k,parentoffsetleft:q,parentoffsettop:r,stellarratio:o.data("stellar-background-ratio")===d?1:o.data("stellar-background-ratio")})}))},_reset:function(){var a,b,c,d,e;for(e=this.particles.length-1;e>=0;e--)a=this.particles[e],b=a.$element.data("stellar-startingleft"),c=a.$element.data("stellar-startingtop"),this._setposition(a.$element,b,b,c,c),this.options.showelement(a.$element),a.$element.data("stellar-startingleft",null).data("stellar-elementisactive",null).data("stellar-backgroundisactive",null);for(e=this.backgrounds.length-1;e>=0;e--)d=this.backgrounds[e],d.$element.data("stellar-backgroundstartingleft",null).data("stellar-backgroundstartingtop",null),m(d.$element,d.startingvalueleft,d.startingvaluetop)},destroy:function(){this._reset(),this.$scrollelement.unbind("resize."+this.name).unbind("scroll."+this.name),this._animationloop=a.noop,a(b).unbind("load."+this.name).unbind("resize."+this.name)},_setoffsets:function(){var c=this,d=a(b);d.unbind("resize.horizontal-"+this.name).unbind("resize.vertical-"+this.name),"function"==typeof this.options.horizontaloffset?(this.horizontaloffset=this.options.horizontaloffset(),d.bind("resize.horizontal-"+this.name,function(){c.horizontaloffset=c.options.horizontaloffset()})):this.horizontaloffset=this.options.horizontaloffset,"function"==typeof this.options.verticaloffset?(this.verticaloffset=this.options.verticaloffset(),d.bind("resize.vertical-"+this.name,function(){c.verticaloffset=c.options.verticaloffset()})):this.verticaloffset=this.options.verticaloffset},_repositionelements:function(){var a,b,c,d,e,f,g,h,i,j,k=this._getscrollleft(),l=this._getscrolltop(),n=!0,o=!0;if(this.currentscrollleft!==k||this.currentscrolltop!==l||this.currentwidth!==this.viewportwidth||this.currentheight!==this.viewportheight){for(this.currentscrollleft=k,this.currentscrolltop=l,this.currentwidth=this.viewportwidth,this.currentheight=this.viewportheight,j=this.particles.length-1;j>=0;j--)a=this.particles[j],b=a.isfixed?1:0,this.options.horizontalscrolling?(f=(k+a.horizontaloffset+this.viewportoffsetleft+a.startingpositionleft-a.startingoffsetleft+a.parentoffsetleft)*-(a.stellarratio+b-1)+a.startingpositionleft,h=f-a.startingpositionleft+a.startingoffsetleft):(f=a.startingpositionleft,h=a.startingoffsetleft),this.options.verticalscrolling?(g=(l+a.verticaloffset+this.viewportoffsettop+a.startingpositiontop-a.startingoffsettop+a.parentoffsettop)*-(a.stellarratio+b-1)+a.startingpositiontop,i=g-a.startingpositiontop+a.startingoffsettop):(g=a.startingpositiontop,i=a.startingoffsettop),this.options.hidedistantelements&&(o=!this.options.horizontalscrolling||h+a.width>(a.isfixed?0:k)&&h<(a.isfixed?0:k)+this.viewportwidth+this.viewportoffsetleft,n=!this.options.verticalscrolling||i+a.height>(a.isfixed?0:l)&&i<(a.isfixed?0:l)+this.viewportheight+this.viewportoffsettop),o&&n?(a.ishidden&&(this.options.showelement(a.$element),a.ishidden=!1),this._setposition(a.$element,f,a.startingpositionleft,g,a.startingpositiontop)):a.ishidden||(this.options.hideelement(a.$element),a.ishidden=!0);for(j=this.backgrounds.length-1;j>=0;j--)c=this.backgrounds[j],b=c.isfixed?0:1,d=this.options.horizontalscrolling?(k+c.horizontaloffset-this.viewportoffsetleft-c.startingoffsetleft+c.parentoffsetleft-c.startingbackgroundpositionleft)*(b-c.stellarratio)+"px":c.startingvalueleft,e=this.options.verticalscrolling?(l+c.verticaloffset-this.viewportoffsettop-c.startingoffsettop+c.parentoffsettop-c.startingbackgroundpositiontop)*(b-c.stellarratio)+"px":c.startingvaluetop,m(c.$element,d,e)}},_handlescrollevent:function(){var a=this,b=!1,c=function(){a._repositionelements(),b=!1},d=function(){b||(o(c),b=!0)};this.$scrollelement.bind("scroll."+this.name,d),d()},_startanimationloop:function(){var a=this;this._animationloop=function(){o(a._animationloop),a._repositionelements()},this._animationloop()}},a.fn[f]=function(b){var c=arguments;return b===d||"object"==typeof b?this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))}):"string"==typeof b&&"_"!==b[0]&&"init"!==b?this.each(function(){var d=a.data(this,"plugin_"+f);d instanceof e&&"function"==typeof d[b]&&d[b].apply(d,array.prototype.slice.call(c,1)),"destroy"===b&&a.data(this,"plugin_"+f,null)}):void 0},a[f]=function(){var c=a(b);return c.stellar.apply(c,array.prototype.slice.call(arguments,0))},a[f].scrollproperty=h,a[f].positionproperty=i,b.stellar=e}(jquery,this,document);