!function(a){var b;window.UIkit&&(b=a(UIkit)),"function"==typeof define&&define.amd&&define("uikit-sticky",["uikit"],function(){return b||a(UIkit)})}(function(a){"use strict";function b(b){var f=arguments.length?arguments:e;if(f.length&&!(c.scrollTop()<0))for(var g,h,i,j,k=c.scrollTop(),l=d.height(),m=c.height(),n=l-m,o=k>n?n-k:0,p=0;pl-h-(j.top<0?0:j.top)?l-h-(k+i):g}if(j.currentTop!=g){if(j.element.css({position:"fixed",top:g,width:j.getWidthFrom.length?j.getWidthFrom.width():j.element.width()}),!j.init&&(j.element.addClass(j.options.clsinit),location.hash&&k>0&&j.options.target)){var r=a.$(location.hash);r.length&&setTimeout(function(a,b){return function(){b.element.width();var c=a.offset(),d=c.top+a.outerHeight(),e=b.element.offset(),f=b.element.outerHeight(),g=e.top+f;e.top').parent(),this.computeWrapper(),this.wrapper.css({"margin-top":this.element.css("margin-top"),"margin-bottom":this.element.css("margin-bottom"),"margin-left":this.element.css("margin-left"),"margin-right":this.element.css("margin-right")}),this.element.css("margin",0),g&&(g===!0||"!"===g[0]?(g=g===!0?this.wrapper.parent():this.wrapper.closest(g.substr(1)),b=!0):"string"==typeof g&&(g=a.$(g))),this.sticky={self:this,options:this.options,element:this.element,currentTop:null,wrapper:this.wrapper,init:!1,getWidthFrom:a.$(this.options.getWidthFrom||this.wrapper),boundary:g,boundtoparent:b,top:0,calcTop:function(){var b=this.options.top;if(this.options.top&&"string"==typeof this.options.top)if(this.options.top.match(/^(-|)(\d+)vh$/))b=window.innerHeight*parseInt(this.options.top,10)/100;else{var c=a.$(this.options.top).first();c.length&&c.is(":visible")&&(b=-1*(c.offset().top+c.outerHeight()-this.wrapper.offset().top))}this.top=b},reset:function(b){this.calcTop();var c=function(){this.element.css({position:"",top:"",width:"",left:"",margin:"0"}),this.element.removeClass([this.options.animation,"uk-animation-reverse",this.options.clsactive].join(" ")),this.element.addClass(this.options.clsinactive),this.element.trigger("inactive.uk.sticky"),this.currentTop=null,this.animate=!1}.bind(this);!b&&this.options.animation&&a.support.animation&&!a.Utils.isInView(this.wrapper)?(this.animate=!0,this.element.removeClass(this.options.animation).one(a.support.animation.end,function(){c()}).width(),this.element.addClass(this.options.animation+" uk-animation-reverse")):c()},check:function(){if(this.options.disabled)return!1;if(this.options.media)switch(typeof this.options.media){case"number":if(window.innerWidthg?g-b:0,i=this.wrapper.offset().top,j=i-this.top-h,k=b>=j;return k&&this.options.showup&&(1==f&&(k=!1),f==-1&&!this.element.hasClass(this.options.clsactive)&&a.Utils.isInView(this.wrapper)&&(k=!1)),k}},this.sticky.calcTop(),e.push(this.sticky)},update:function(){b(this.sticky)},enable:function(){this.options.disabled=!1,this.update()},disable:function(a){this.options.disabled=!0,this.sticky.reset(a)},computeWrapper:function(){this.wrapper.css({height:["absolute","fixed"].indexOf(this.element.css("position"))==-1?this.element.outerHeight():"",float:"none"!=this.element.css("float")?this.element.css("float"):""}),"fixed"==this.element.css("position")&&this.element.css({width:this.sticky.getWidthFrom.length?this.sticky.getWidthFrom.width():this.element.width()})}}),a.sticky});