; /*! * js v0.6.2 * http://markdalgleish/projects/js * * Copyright 2025, Mark Dalgleish * This content is released under the MIT license * # */ (function($,window,document,undefined){var pluginName='stellar',defaults={scrollProperty:'scroll',positionProperty:'position',horizontalScrolling:true,verticalScrolling:true,horizontalOffset:0,verticalOffset:0,responsive:false,parallaxBackgrounds:true,parallaxElements:true,hideDistantElements:true,hideElement:function($elem){$hide();},showElement:function($elem){$show();}},scrollProperty={scroll:{getLeft:function($elem){return $scrollleft();},setLeft:function($elem,val){$scrollleft(val);},getTop:function($elem){return $scrolltop();},setTop:function($elem,val){$scrolltop(val);}},position:{getLeft:function($elem){return parseInt($css('left'),10)*-1;},getTop:function($elem){return parseInt($css('top'),10)*-1;}},margin:{getLeft:function($elem){return parseInt($css('margin-left'),10)*-1;},getTop:function($elem){return parseInt($css('margin-top'),10)*-1;}},transform:{getLeft:function($elem){var computedTransform=getComputedStyle($elem[0])[prefixedTransform];return(computedTransform!=='none'?parseInt(match(/(-?[0-9]+)/g)[4],10)*-1:0);},getTop:function($elem){var computedTransform=getComputedStyle($elem[0])[prefixedTransform];return(computedTransform!=='none'?parseInt(match(/(-?[0-9]+)/g)[5],10)*-1:0);}}},positionProperty={position:{setLeft:function($elem,left){$css('left',left);},setTop:function($elem,top){$css('top',top);}},transform:{setPosition:function($elem,left,startingLeft,top,startingTop){$elem[0].style[prefixedTransform]='translate3d('+(left-startingLeft)+'px, '+(top-startingTop)+'px, 0)';}}},vendorPrefix=(function(){var prefixes=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,style=$('script')[0].style,prefix='',prop;for(prop in style){if(test(prop)){prefix=match(prefixes)[0];break;}} if('WebkitOpacity'in style){prefix='Webkit';} if('KhtmlOpacity'in style){prefix='Khtml';} return function(property){return prefix+(length>0?charat(0).toUpperCase()+slice(1):property);};}()),prefixedTransform=vendorPrefix('transform'),supportsBackgroundPositionXY=$('
',{style:'background:#fff'}).css('background-position-x')!==undefined,setBackgroundPosition=(supportsBackgroundPositionXY?function($elem,x,y){$css({'background-position-x':x,'background-position-y':y});}:function($elem,x,y){$css('background-position',x+' '+y);}),getBackgroundPosition=(supportsBackgroundPositionXY?function($elem){return[$css('background-position-x'),$css('background-position-y')];}:function($elem){return $css('background-position').split(' ');}),requestAnimFrame=(requestanimationframe||webkitrequestanimationframe||mozrequestanimationframe||orequestanimationframe||msrequestanimationframe||function(callback){setTimeout(callback,1000/60);});function Plugin(element,options){element=element;options=$.extend({},defaults,options);this._defaults=defaults;this._name=pluginName;init();} prototype={init:function(){name=pluginName+'_'+floor(random()*1e9);this._defineElements();this._defineGetters();this._defineSetters();this._handleWindowLoadAndResize();this._detectViewport();refresh({firstLoad:true});if(scrollproperty==='scroll'){this._handleScrollEvent();}else{this._startAnimationLoop();}},_defineElements:function(){if(element===body)element=window;this.$scrollElement=$(element);this.$element=(element===window?$('body'):this.$scrollElement);this.$viewportElement=(viewportelement!==undefined?$(viewportelement):(this.$scrollElement[0]===window||scrollproperty==='scroll'?this.$scrollElement:this.$parent()));},_defineGetters:function(){var self=this,scrollPropertyAdapter=scrollProperty[scrollproperty];this._getScrollLeft=function(){return getleft(self.$scrollElement);};this._getScrollTop=function(){return gettop(self.$scrollElement);};},_defineSetters:function(){var self=this,scrollPropertyAdapter=scrollProperty[scrollproperty],positionPropertyAdapter=positionProperty[positionproperty],setScrollLeft=setleft,setScrollTop=settop;this._setScrollLeft=(typeof setScrollLeft==='function'?function(val){setScrollLeft(self.$scrollElement,val);}:$.noop);this._setScrollTop=(typeof setScrollTop==='function'?function(val){setScrollTop(self.$scrollElement,val);}:$.noop);this._setPosition=setposition||function($elem,left,startingLeft,top,startingTop){if(horizontalscrolling){setleft($elem,left,startingLeft);} if(verticalscrolling){settop($elem,top,startingTop);}};},_handleWindowLoadAndResize:function(){var self=this,$window=$(window);if(responsive){$bind('load.'+name,function(){refresh();});} $bind('resize.'+name,function(){self._detectViewport();if(responsive){refresh();}});},refresh:function(options){var self=this,oldLeft=self._getScrollLeft(),oldTop=self._getScrollTop();if(!options||!firstload){this._reset();} this._setScrollLeft(0);this._setScrollTop(0);this._setOffsets();this._findParticles();this._findBackgrounds();if(options&&firstload&&/WebKit/.test(useragent)){$(window).load(function(){var oldLeft=self._getScrollLeft(),oldTop=self._getScrollTop();self._setScrollLeft(oldLeft+1);self._setScrollTop(oldTop+1);self._setScrollLeft(oldLeft);self._setScrollTop(oldTop);});} this._setScrollLeft(oldLeft);this._setScrollTop(oldTop);},_detectViewport:function(){var viewportOffsets=this.$offset(),hasOffsets=viewportOffsets!==null&&viewportOffsets!==undefined;viewportwidth=this.$width();viewportheight=this.$height();viewportoffsettop=(hasOffsets?top:0);viewportoffsetleft=(hasOffsets?left:0);},_findParticles:function(){var self=this,scrollLeft=this._getScrollLeft(),scrollTop=this._getScrollTop();if(particles!==undefined){for(var i=length-1;i>=0;i--){particles[i].$data('stellar-elementIsActive',undefined);}} particles=[];if(!parallaxelements)return;this.$find('[data-stellar-ratio]').each(function(i){var $this=$(this),horizontalOffset,verticalOffset,positionLeft,positionTop,marginLeft,marginTop,$offsetParent,offsetLeft,offsetTop,parentOffsetLeft=0,parentOffsetTop=0,tempParentOffsetLeft=0,tempParentOffsetTop=0;if(!$data('stellar-elementIsActive')){$data('stellar-elementIsActive',this);}else if($data('stellar-elementIsActive')!==this){return;} showelement($this);if(!$data('stellar-startingLeft')){$data('stellar-startingLeft',$css('left'));$data('stellar-startingTop',$css('top'));}else{$css('left',$data('stellar-startingLeft'));$css('top',$data('stellar-startingTop'));} positionLeft=$position().left;positionTop=$position().top;marginLeft=($css('margin-left')==='auto')?0:parseInt($css('margin-left'),10);marginTop=($css('margin-top')==='auto')?0:parseInt($css('margin-top'),10);offsetLeft=$offset().left-marginLeft;offsetTop=$offset().top-marginTop;$parents().each(function(){var $this=$(this);if($data('stellar-offset-parent')===true){parentOffsetLeft=tempParentOffsetLeft;parentOffsetTop=tempParentOffsetTop;$offsetParent=$this;return false;}else{tempParentOffsetLeft+=$position().left;tempParentOffsetTop+=$position().top;}});horizontalOffset=($data('stellar-horizontal-offset')!==undefined?$data('stellar-horizontal-offset'):($offsetParent!==undefined&&$data('stellar-horizontal-offset')!==undefined?$data('stellar-horizontal-offset'):horizontaloffset));verticalOffset=($data('stellar-vertical-offset')!==undefined?$data('stellar-vertical-offset'):($offsetParent!==undefined&&$data('stellar-vertical-offset')!==undefined?$data('stellar-vertical-offset'):verticaloffset));push({$element:$this,$offsetParent:$offsetParent,isFixed:$css('position')==='fixed',horizontalOffset:horizontalOffset,verticalOffset:verticalOffset,startingPositionLeft:positionLeft,startingPositionTop:positionTop,startingOffsetLeft:offsetLeft,startingOffsetTop:offsetTop,parentOffsetLeft:parentOffsetLeft,parentOffsetTop:parentOffsetTop,stellarRatio:($data('stellar-ratio')!==undefined?$data('stellar-ratio'):1),width:$outerwidth(true),height:$outerheight(true),isHidden:false});});},_findBackgrounds:function(){var self=this,scrollLeft=this._getScrollLeft(),scrollTop=this._getScrollTop(),$backgroundElements;backgrounds=[];if(!parallaxbackgrounds)return;$backgroundElements=this.$find('[data-stellar-background-ratio]');if(this.$data('stellar-background-ratio')){$backgroundElements=$add(this.$element);} $each(function(){var $this=$(this),backgroundPosition=getBackgroundPosition($this),horizontalOffset,verticalOffset,positionLeft,positionTop,marginLeft,marginTop,offsetLeft,offsetTop,$offsetParent,parentOffsetLeft=0,parentOffsetTop=0,tempParentOffsetLeft=0,tempParentOffsetTop=0;if(!$data('stellar-backgroundIsActive')){$data('stellar-backgroundIsActive',this);}else if($data('stellar-backgroundIsActive')!==this){return;} if(!$data('stellar-backgroundStartingLeft')){$data('stellar-backgroundStartingLeft',backgroundPosition[0]);$data('stellar-backgroundStartingTop',backgroundPosition[1]);}else{setBackgroundPosition($this,$data('stellar-backgroundStartingLeft'),$data('stellar-backgroundStartingTop'));} marginLeft=($css('margin-left')==='auto')?0:parseInt($css('margin-left'),10);marginTop=($css('margin-top')==='auto')?0:parseInt($css('margin-top'),10);offsetLeft=$offset().left-marginLeft-scrollLeft;offsetTop=$offset().top-marginTop-scrollTop;$parents().each(function(){var $this=$(this);if($data('stellar-offset-parent')===true){parentOffsetLeft=tempParentOffsetLeft;parentOffsetTop=tempParentOffsetTop;$offsetParent=$this;return false;}else{tempParentOffsetLeft+=$position().left;tempParentOffsetTop+=$position().top;}});horizontalOffset=($data('stellar-horizontal-offset')!==undefined?$data('stellar-horizontal-offset'):($offsetParent!==undefined&&$data('stellar-horizontal-offset')!==undefined?$data('stellar-horizontal-offset'):horizontaloffset));verticalOffset=($data('stellar-vertical-offset')!==undefined?$data('stellar-vertical-offset'):($offsetParent!==undefined&&$data('stellar-vertical-offset')!==undefined?$data('stellar-vertical-offset'):verticaloffset));push({$element:$this,$offsetParent:$offsetParent,isFixed:$css('background-attachment')==='fixed',horizontalOffset:horizontalOffset,verticalOffset:verticalOffset,startingValueLeft:backgroundPosition[0],startingValueTop:backgroundPosition[1],startingBackgroundPositionLeft:(isNaN(parseInt(backgroundPosition[0],10))?0:parseInt(backgroundPosition[0],10)),startingBackgroundPositionTop:(isNaN(parseInt(backgroundPosition[1],10))?0:parseInt(backgroundPosition[1],10)),startingPositionLeft:$position().left,startingPositionTop:$position().top,startingOffsetLeft:offsetLeft,startingOffsetTop:offsetTop,parentOffsetLeft:parentOffsetLeft,parentOffsetTop:parentOffsetTop,stellarRatio:($data('stellar-background-ratio')===undefined?1:$data('stellar-background-ratio'))});});},_reset:function(){var particle,startingPositionLeft,startingPositionTop,background,i;for(i=length-1;i>=0;i--){particle=particles[i];startingPositionLeft=particle.$data('stellar-startingLeft');startingPositionTop=particle.$data('stellar-startingTop');this._setPosition(particle.$element,startingPositionLeft,startingPositionLeft,startingPositionTop,startingPositionTop);showelement(particle.$element);particle.$data('stellar-startingLeft',null).data('stellar-elementIsActive',null).data('stellar-backgroundIsActive',null);} for(i=length-1;i>=0;i--){background=backgrounds[i];background.$data('stellar-backgroundStartingLeft',null).data('stellar-backgroundStartingTop',null);setBackgroundPosition(background.$element,startingvalueleft,startingvaluetop);}},destroy:function(){this._reset();this.$unbind('resize.'+name).unbind('scroll.'+name);this._animationLoop=$.noop;$(window).unbind('load.'+name).unbind('resize.'+name);},_setOffsets:function(){var self=this,$window=$(window);$unbind('horizontal-'+name).unbind('vertical-'+name);if(typeof horizontaloffset==='function'){horizontaloffset=horizontaloffset();$bind('horizontal-'+name,function(){horizontaloffset=horizontaloffset();});}else{horizontaloffset=horizontaloffset;} if(typeof verticaloffset==='function'){verticaloffset=verticaloffset();$bind('vertical-'+name,function(){verticaloffset=verticaloffset();});}else{verticaloffset=verticaloffset;}},_repositionElements:function(){var scrollLeft=this._getScrollLeft(),scrollTop=this._getScrollTop(),horizontalOffset,verticalOffset,particle,fixedRatioOffset,background,bgLeft,bgTop,isVisibleVertical=true,isVisibleHorizontal=true,newPositionLeft,newPositionTop,newOffsetLeft,newOffsetTop,i;if(currentscrollleft===scrollLeft&¤tscrolltop===scrollTop&¤twidth===viewportwidth&¤theight===viewportheight){return;}else{currentscrollleft=scrollLeft;currentscrolltop=scrollTop;currentwidth=viewportwidth;currentheight=viewportheight;} for(i=length-1;i>=0;i--){particle=particles[i];fixedRatioOffset=(isfixed?1:0);if(horizontalscrolling){newPositionLeft=(scrollLeft+horizontaloffset+viewportoffsetleft+startingoffsetleft+parentoffsetleft)*-(stellarratio+fixedRatioOffset-1)+startingpositionleft;newOffsetLeft=startingpositionleft+startingoffsetleft;}else{newPositionLeft=startingpositionleft;newOffsetLeft=startingoffsetleft;} if(verticalscrolling){newPositionTop=(scrollTop+verticaloffset+viewportoffsettop+startingoffsettop+parentoffsettop)*-(stellarratio+fixedRatioOffset-1)+startingpositiontop;newOffsetTop=startingpositiontop+startingoffsettop;}else{newPositionTop=startingpositiontop;newOffsetTop=startingoffsettop;} if(hidedistantelements){isVisibleHorizontal=!horizontalscrolling||newOffsetLeft+width>(isfixed?0:scrollLeft)&&newOffsetLeft<(isfixed?0:scrollLeft)+viewportwidth+viewportoffsetleft;isVisibleVertical=!verticalscrolling||newOffsetTop+height>(isfixed?0:scrollTop)&&newOffsetTop<(isfixed?0:scrollTop)+viewportheight+viewportoffsettop;} if(isVisibleHorizontal&&isVisibleVertical){if(ishidden){showelement(particle.$element);ishidden=false;} this._setPosition(particle.$element,newPositionLeft,startingpositionleft,newPositionTop,startingpositiontop);}else{if(!ishidden){hideelement(particle.$element);ishidden=true;}}} for(i=length-1;i>=0;i--){background=backgrounds[i];fixedRatioOffset=(isfixed?0:1);bgLeft=(horizontalscrolling?(scrollLeft+startingoffsetleft+startingbackgroundpositionleft)*(stellarratio)+'px':startingvalueleft);bgTop=(verticalscrolling?(scrollTop+startingoffsettop+startingbackgroundpositiontop)*(stellarratio)+'px':startingvaluetop);setBackgroundPosition(background.$element,bgLeft,bgTop);}},_handleScrollEvent:function(){var self=this,ticking=false;var update=function(){self._repositionElements();ticking=false;};var requestTick=function(){if(!ticking){requestAnimFrame(update);ticking=true;}};this.$bind('scroll.'+name,requestTick);requestTick();},_startAnimationLoop:function(){var self=this;this._animationLoop=function(){requestAnimFrame(self._animationLoop);self._repositionElements();};this._animationLoop();}};$.fn[pluginName]=function(options){var args=arguments;if(options===undefined||typeof options==='object'){return each(function(){if(!$.data(this,'plugin_'+pluginName)){$.data(this,'plugin_'+pluginName,new Plugin(this,options));}});}else if(typeof options==='string'&&options[0]!=='_'&&options!=='init'){return each(function(){var instance=$.data(this,'plugin_'+pluginName);if(instance instanceof Plugin&&typeof instance[options]==='function'){instance[options].apply(instance,call(args,1));} if(options==='destroy'){$.data(this,'plugin_'+pluginName,null);}});}};$[pluginName]=function(options){var $window=$(window);return $apply($window,call(arguments,0));};$[pluginName].scrollProperty=scrollProperty;$[pluginName].positionProperty=positionProperty;stellar=Plugin;}(jQuery,this,document));