define(['jquery','jquery-ui-modules/widget'],function($){'use strict';$.widget('mage.sticky',{options:{container:'',spacingTop:0,stickAfter:0,stickyClass:'_sticky'},_getOptionValue:function(option){var value=this.options[option]||0;if(typeof value==='function'){value=this.options[option]();} return value;},_create:function(){$(window).on({'scroll':$.proxy(this._stick,this),'resize':$.proxy(this.reset,this)});this.element.on('dimensionsChanged',$.proxy(this.reset,this));this.reset();this.normalizeIE11AndEdgeScroll();},_stick:function(){var offset,isStatic,stuck,stickAfter;isStatic=this.element.css('position')==='static';if(!isStatic&&this.element.is(':visible')){offset=$(document).scrollTop()- this.parentOffset+ this._getOptionValue('spacingTop');offset=Math.max(0,Math.min(offset,this.maxOffset));stuck=this.element.hasClass(this.options.stickyClass);stickAfter=this._getOptionValue('stickAfter');if(offset&&!stuck&&offset0).css('top',offset);}},_calculateDimens:function(){var $parent=this.element.parent(),topMargin=parseInt(this.element.css('margin-top'),10),parentHeight=$parent.height()-topMargin,height=this.element.innerHeight(),maxScroll=document.body.offsetHeight-window.innerHeight;if(this.options.container.length>0){maxScroll=$(this.options.container).height();} this.parentOffset=$parent.offset().top+topMargin;this.maxOffset=maxScroll-this.parentOffset;if(this.maxOffset+height>=parentHeight){this.maxOffset=parentHeight-height;} return this;},reset:function(){this._calculateDimens()._stick();},normalizeIE11AndEdgeScroll:function(){if(navigator.userAgent.match(/Trident.*rv[ :]*11\.|Edge\//)){document.body.addEventListener('mousewheel',function(){event.preventDefault();window.scrollTo(0,window.pageYOffset-event.wheelDelta);});}}});return $.mage.sticky;});