/*! * hc-sticky * ========= * version: 2.1.0 * author: some web media * author url: http://somewebmedia.com * plugin url: https://github.com/somewebmedia/hc-sticky * description: cross-browser plugin that makes any element on your page visible while you scroll * license: mit */ !function(t,e){"use strict";if("object"==typeof module&&"object"==typeof module.exports){if(!t.document)throw new error("hc-sticky requires a browser to run.");module.exports=e(t)}else"function"==typeof define&&define.amd?define("hcsticky",[],e(t)):e(t)}("undefined"!=typeof window?window:this,function(t){"use strict";var e={top:0,bottom:0,bottomend:0,innertop:0,innersticker:null,stickyclass:"sticky",stickto:null,followscroll:!0,queries:null,queryflow:"down",onstart:null,onstop:null,onbeforeresize:null,onresize:null,resizedebounce:100,disable:!1},o=t.document,i=function(n,s){if("string"==typeof n&&(n=o.queryselector(n)),!n)return!1;var r={},l=i.helpers,a=n.parentnode;"static"===l.getstyle(a,"position")&&(a.style.position="relative");var c=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l.isemptyobject(t)&&r||(r=object.assign({},e,r,t))},f=function(){return r.disable},d=function(){if(r.queries){var o=t.innerwidth,i=r.queryflow,n=r.queries;if(function(t){r=object.assign({},e,t||{})}(s),"up"===i)for(var a in n)o>=a&&!l.isemptyobject(n[a])&&c(n[a]);else{var f=[];for(var d in r.queries){var u={};u[d]=n[d],f.push(u)}for(var p=f.length-1;p>=0;p--){var g=f[p],m=object.keys(g)[0];o<=m&&!l.isemptyobject(g[m])&&c(g[m])}}}},u={css:{},position:null,stick:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};l.hasclass(n,r.stickyclass)||(!1===p.isattached&&p.attach(),u.position="fixed",n.style.position="fixed",n.style.left=p.offsetleft+"px",n.style.width=p.width,void 0===t.bottom?n.style.bottom="auto":n.style.bottom=t.bottom+"px",void 0===t.top?n.style.top="auto":n.style.top=t.top+"px",n.classlist?n.classlist.add(r.stickyclass):n.classname+=" "+r.stickyclass,r.onstart&&r.onstart.call(n,r))},reset:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.disable=t.disable||!1,"fixed"===u.position||null===u.position||!(void 0===t.top&&void 0===t.bottom||void 0!==t.top&&(parseint(l.getstyle(n,"top"))||0)===t.top||void 0!==t.bottom&&(parseint(l.getstyle(n,"bottom"))||0)===t.bottom)){!0===t.disable?!0===p.isattached&&p.detach():!1===p.isattached&&p.attach();var e=t.position||u.css.position;u.position=e,n.style.position=e,n.style.left=!0===t.disable?u.css.left:p.positionleft+"px",n.style.width="absolute"!==e?u.css.width:p.width,void 0===t.bottom?n.style.bottom=!0===t.disable?"":"auto":n.style.bottom=t.bottom+"px",void 0===t.top?n.style.top=!0===t.disable?"":"auto":n.style.top=t.top+"px",n.classlist?n.classlist.remove(r.stickyclass):n.classname=n.classname.replace(new regexp("(^|\\b)"+r.stickyclass.split(" ").join("|")+"(\\b|$)","gi")," "),r.onstop&&r.onstop.call(n,r)}}},p={el:o.createelement("div"),offsetleft:null,positionleft:null,width:null,isattached:!1,init:function(){for(var t in u.css)p.el.style[t]=u.css[t];var e=l.getstyle(n);p.offsetleft=l.offset(n).left-(parseint(e.marginleft)||0),p.positionleft=l.position(n).left,p.width=l.getstyle(n,"width")},attach:function(){a.insertbefore(p.el,n.nextsibling),p.isattached=!0},detach:function(){p.el=a.removechild(p.el),p.isattached=!1}},g=void 0,m=void 0,v=void 0,h=void 0,y=void 0,b=void 0,s=void 0,w=void 0,k=void 0,x=void 0,l=void 0,e=void 0,t=void 0,c=void 0,j=void 0,z=void 0,n=void 0,o=void 0,r=function(){u.css=function(t){var e=l.getcascadedstyle(t),o=l.getstyle(t),i={height:t.offsetheight+"px",left:e.left,right:e.right,top:e.top,bottom:e.bottom,position:o.position,display:o.display,verticalalign:o.verticalalign,boxsizing:o.boxsizing,marginleft:e.marginleft,marginright:e.marginright,margintop:e.margintop,marginbottom:e.marginbottom,paddingleft:e.paddingleft,paddingright:e.paddingright};return e.float&&(i.float=e.float||"none"),e.cssfloat&&(i.cssfloat=e.cssfloat||"none"),o.mozboxsizing&&(i.mozboxsizing=o.mozboxsizing),i.width="auto"!==e.width?e.width:"border-box"===i.boxsizing||"border-box"===i.mozboxsizing?t.offsetwidth+"px":o.width,i}(n),p.init(),g=!(!r.stickto||!("document"===r.stickto||r.stickto.nodetype&&9===r.stickto.nodetype||"object"==typeof r.stickto&&r.stickto instanceof("undefined"!=typeof htmldocument?htmldocument:document))),m=r.stickto?g?o:"string"==typeof r.stickto?o.queryselector(r.stickto):r.stickto:a,j=(o=function(){var t=n.offsetheight+(parseint(u.css.margintop)||0)+(parseint(u.css.marginbottom)||0),e=(j||0)-t;return e>=-1&&e<=1?j:t})(),h=(n=function(){return g?math.max(o.documentelement.clientheight,o.body.scrollheight,o.documentelement.scrollheight,o.body.offsetheight,o.documentelement.offsetheight):m.offsetheight})(),y=g?0:l.offset(m).top,b=r.stickto?g?0:l.offset(a).top:y,s=t.innerheight,z=n.offsettop-(parseint(u.css.margintop)||0),v=r.innersticker?"string"==typeof r.innersticker?o.queryselector(r.innersticker):r.innersticker:null,w=isnan(r.top)&&r.top.indexof("%")>-1?parsefloat(r.top)/100*s:r.top,k=isnan(r.bottom)&&r.bottom.indexof("%")>-1?parsefloat(r.bottom)/100*s:r.bottom,x=v?v.offsettop:r.innertop?r.innertop:0,l=isnan(r.bottomend)&&r.bottomend.indexof("%")>-1?parsefloat(r.bottomend)/100*s:r.bottomend,e=y-w+x+z},h=t.pageyoffset||o.documentelement.scrolltop,b=0,i=void 0,q=function(){j=o(),h=n(),t=y+h-w-l,c=j>s;var e=t.pageyoffset||o.documentelement.scrolltop,i=l.offset(n).top,s=i-e,c=void 0;i=ee?t+w+(c?k:0)-(r.followscroll&&c?0:w)<=e+j-x-(j-x>s-(e-x)&&r.followscroll&&(c=j-s-x)>0?c:0)?u.reset({position:"absolute",bottom:b+a.offsetheight-t-w}):c&&r.followscroll?"down"===i?s+j+k<=s?u.stick({bottom:k}):"fixed"===u.position&&u.reset({position:"absolute",top:i-w-e-b+x}):s+x<0&&"fixed"===u.position?u.reset({position:"absolute",top:i-w-e+x-b}):i>=e+w-x&&u.stick({top:w-x}):u.stick({top:w-x}):u.reset({disable:!0})},a=!1,f=!1,m=function(){a&&(l.event.unbind(t,"scroll",q),a=!1)},d=function(){r(),j>=h?m():(q(),a||(l.event.bind(t,"scroll",q),a=!0))},w=function(){n.style.position="",n.style.left="",n.style.top="",n.style.bottom="",n.style.width="",n.classlist?n.classlist.remove(r.stickyclass):n.classname=n.classname.replace(new regexp("(^|\\b)"+r.stickyclass.split(" ").join("|")+"(\\b|$)","gi")," "),u.css={},u.position=null,!0===p.isattached&&p.detach()},p=function(){w(),d(),f()?m():d()},v=function(){r.onbeforeresize&&r.onbeforeresize.call(n,r),p(),r.onresize&&r.onresize.call(n,r)},y=r.resizedebounce?l.debounce(v,r.resizedebounce):v,$=function(){f&&(l.event.unbind(t,"resize",y),f=!1),m()},q=function(){f||(l.event.bind(t,"resize",y),f=!0),d(),f()?m():d()};this.options=function(t){return t?r.option||null:object.assign({},r)},this.reinit=p,this.update=function(t){c(t),p()},this.attach=q,this.detach=$,this.destroy=function(){$(),w()},c(s),q(),l.event.bind(t,"load",p)};if(void 0!==t.jquery){var n=t.jquery;n.fn.extend({hcsticky:function(t){return this.length?this.each(function(){var e=n.data(this,"hcsticky");e?e.update(t):(e=new i(this,t),n.data(this,"hcsticky",e))}):this}})}return t.hcsticky=t.hcsticky||i,i}),function(t){"use strict";var e=t.hcsticky,o=t.document;"function"!=typeof object.assign&&object.defineproperty(object,"assign",{value:function(t,e){if(null==t)throw new typeerror("cannot convert undefined or null to object");for(var o=object(t),i=1;i