/*! * sticky-state 2.4.1 - StickyState is a high performant module making native position:sticky statefull and polyfill the missing sticky browser feature * Copyright (c) 2016 Sönke Kluth (http://soenkekluth.com/) - https://github.com/soenkekluth/sticky-state#readme * License: MIT */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StickyState=e():t.StickyState=e()}(this,function(){return function(t){function e(s){if(i[s])return i[s].exports;var n=i[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){t.exports=i(2)},function(t,e){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t){return!t||0===Object.keys(t).length}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=e.target,n=e.currentTarget;i(this,t),this.target=s||this,this.currentTarget=n||this,this.eventMap={},this.destroyed=!1,this.on=this.bind=this.addEventListener=this.addListener,this.off=this.unbind=this.removeEventListener=this.removeListener,this.once=this.one=this.addListenerOnce,this.emit=this.trigger=this.dispatchEvent=this.dispatch}return t.prototype.addListener=function(t,e){var i=this.getListener(t);return i?i.indexOf(e)===-1&&i.push(e):this.eventMap[t]=[e],this},t.prototype.addListenerOnce=function(t,e){var i=this,s=function s(n){e(n),i.off(t,s)};return this.on(t,s)},t.prototype.removeListener=function(t,e){if(!e)return this.removeAllListener(t);var i=this.getListener(t);if(i){var s=i.indexOf(e);s>-1&&(i.splice(s,1),i.length||delete this.eventMap[t])}return this},t.prototype.removeAllListener=function(t){var e=this.getListener(t);return e&&(this.eventMap[t].length=0,delete this.eventMap[t]),this},t.prototype.hasListener=function(t){return null!==this.getListener(t)},t.prototype.hasListeners=function(){return null!==this.eventMap&&void 0!==this.eventMap&&!s(this.eventMap)},t.prototype.dispatch=function(t,e){var i=this.getListener(t);if(i){var s=e||{};s.type=t,s.target=s.target||this.target,s.currentTarget=s.currentTarget||this.currentTarget;for(var n=-1;++n0&&this.scroll.trigger("scroll:progress")}},e.prototype.removeSrollHandler=function(){this.scroll&&(this.scroll.off("scroll:start",this.onScroll),this.scroll.off("scroll:progress",this.onScroll),this.scroll.off("scroll:stop",this.onScroll),this.options.scrollClass.active&&(this.scroll.off("scroll:up",this.onScrollDirection),this.scroll.off("scroll:down",this.onScrollDirection),this.scroll.off("scroll:stop",this.onScrollDirection)),this.scroll.hasListeners()||this.scroll.destroy(),this.onScroll=null,this.onScrollDirection=null,this.scroll=null)},e.prototype.addResizeHandler=function(){this.onResize||(this.onResize=this.update.bind(this),window.addEventListener("sticky:update",this.onResize,!1),window.addEventListener("resize",this.onResize,!1),window.addEventListener("orientationchange",this.onResize,!1))},e.prototype.removeResizeHandler=function(){this.onResize&&(window.removeEventListener("sticky:update",this.onResize),window.removeEventListener("resize",this.onResize),window.removeEventListener("orientationchange",this.onResize),this.onResize=null)},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.removeSrollHandler(),this.removeResizeHandler(),this.render=null,this.el=null,this.state=null,this.wrapper=null},e.prototype.getScrollClasses=function(t){if(this.options.scrollClass.active){t=t||{};var e=this.scroll.y<=0||this.scroll.y+this.scroll.clientHeight>=this.scroll.scrollHeight?0:this.scroll.directionY;t[this.options.scrollClass.up]=e<0,t[this.options.scrollClass.down]=e>0}return t},e.prototype.onScrollDirection=function(t){(this.state.sticky||t.type===g.default.events.SCROLL_STOP)&&(this.el.className=(0,u.default)(this.el.className,this.getScrollClasses()))},e.prototype.onScroll=function(t){this.updateStickyState(!1),this.hasOwnScrollTarget&&!x.sticky&&(this.updateFixedOffset(),this.state.sticky&&!this.hasWindowScrollListener?(this.hasWindowScrollListener=!0,g.default.getInstance(window).on("scroll:progress",this.updateFixedOffset)):!this.state.sticky&&this.hasWindowScrollListener&&(this.hasWindowScrollListener=!1,g.default.getInstance(window).off("scroll:progress",this.updateFixedOffset)))},e.prototype.update=function(){this.scroll.updateScrollPosition(),this.updateBounds(!0,!0),this.updateStickyState(!1)},e.prototype.getStickyState=function(){if(this.state.disabled)return{sticky:!1,absolute:!1};var t=this.scroll.y,e=(this.scroll.x,this.state.style.top),i=this.state.style.bottom,s=this.state.sticky,n=this.state.absolute;if(null!==e){var o=this.state.restrict.bottom-this.state.bounds.height-e;e=this.state.bounds.top-e,this.state.sticky===!1&&(t>=e&&t<=o||e<=0&&t0&&to)&&(s=!1,n=t>o)}else if(null!==i){t+=window.innerHeight;var r=this.state.restrict.top+this.state.bounds.height-i;i=this.state.bounds.bottom+i,this.state.sticky===!1&&t<=i&&t>=r?(s=!0,n=!1):this.state.sticky&&(t>i||t-1&&s.splice(h,1)}}return s}function s(){return i.apply(null,arguments).join(" ")}var n={}.hasOwnProperty;t.exports=s},function(t,e){"use strict";function i(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function s(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},i=0;i<10;i++)e["_"+String.fromCharCode(i)]=i;var s=Object.getOwnPropertyNames(e).map(function(t){return e[t]});if("0123456789"!==s.join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}var n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=s()?Object.assign:function(t,e){for(var s,r,l=i(t),a=1;a0&&void 0!==arguments[0]?arguments[0]:window,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n(this,e),e.hasInstance(i)){var r;return r=e.getInstance(i),o(l,r)}var l=o(this,t.call(this,{target:i}));return l._scrollTarget=null,l._y=0,l._x=0,l._speedY=0,l._speedX=0,l._lastSpeed=0,l._lastDirectionY=e.direction.none,l._lastDirectionX=e.direction.none,l._stopFrames=3,l._currentStopFrames=0,l._firstRender=!0,l._directionY=e.direction.none,l._directionX=e.direction.none,l._scrolling=!1,l._canScrollY=!1,l._canScrollX=!1,i.scrollFeatures=l,l._scrollTarget=i,l.options=s,g.animationFrame&&d(),l.init(),l}return r(e,t),e.getInstance=function(t,i){return t.scrollFeatures?t.scrollFeatures:new e(t,i)},e.hasInstance=function(t){return"undefined"!=typeof t.scrollFeatures},e.getScrollParent=function(t){return(0,u.default)(t)},l(e,null,[{key:"windowY",get:function(){return window.pageYOffset||window.scrollY||0}},{key:"windowX",get:function(){return window.pageXOffset||window.scrollX||0}},{key:"documentHeight",get:function(){return Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)}},{key:"documentWidth",get:function(){return Math.max(document.body.scrollWidth,document.body.offsetWidth,document.documentElement.clientWidth,document.documentElement.scrollWidth,document.documentElement.offsetWidth)}}]),e.prototype.init=function(){var t=this;if(this.getScrollPosition=this._scrollTarget===window?function(){return{y:e.windowY,x:e.windowX}}.bind(this):function(){return{y:this._scrollTarget.scrollTop,x:this._scrollTarget.scrollLeft}}.bind(this),this.onResize=function(){t.trigger(e.events.SCROLL_RESIZE)},this.onScroll=this.onScroll.bind(this),this.onNextFrame=this.onNextFrame.bind(this),this.updateScrollPosition(),this._scrollTarget!==window){var i=/(auto|scroll)/,s=window.getComputedStyle(this._scrollTarget,null);this._canScrollY=i.test(s.getPropertyValue("overflow-y")),this._canScrollX=i.test(s.getPropertyValue("overflow-x"))}else this._canScrollY=this.clientHeight1||this.x>1)?(this.updateScrollPosition(),void this.trigger(e.events.SCROLL_PROGRESS)):void(this._scrolling||(this._scrolling=!0,this._lastDirectionY=e.direction.none,this._lastDirectionX=e.direction.none,this.trigger(e.events.SCROLL_START),g.animationFrame?this.nextFrameID=window.requestAnimationFrame(this.onNextFrame):this.onNextFrame()))},e.prototype.onNextFrame=function(){var t=this;this._speedY=this._y-this.y,this._speedX=this._x-this.x;var i=+this.speedY+ +this.speedX;return this._scrolling&&0===i&&this._currentStopFrames++>this._stopFrames?void this.onScrollStop():(this.updateScrollPosition(),this._lastDirectionY!==this.directionY&&this.trigger("scroll:"+(this.directionY===e.direction.down?"down":"up")),this._lastDirectionX!==this.directionX&&this.trigger("scroll:"+(this.directionX===e.direction.right?"right":"left")),this._lastDirectionY=this.directionY,this._lastDirectionX=this.directionX,this.trigger(e.events.SCROLL_PROGRESS),void(g.animationFrame?this.nextFrameID=window.requestAnimationFrame(this.onNextFrame):this._nextTimeout=setTimeout(function(){t.onNextFrame()},1e3/60)))},e.prototype.onScrollStop=function(){this._scrolling=!1,this.updateScrollPosition(),this.trigger(e.events.SCROLL_STOP),this._canScrollY&&(this.y<=0?this.trigger(e.events.SCROLL_MIN):this.y+this.clientHeight>=this.scrollHeight&&this.trigger(e.events.SCROLL_MAX)),this._canScrollX&&(this.x<=0?this.trigger(e.events.SCROLL_MIN):this.x+this.clientWidth>=this.scrollWidth&&this.trigger(e.events.SCROLL_MAX)),this._cancelNextFrame()},e.prototype._cancelNextFrame=function(){this._currentStopFrames=0,g.animationFrame?(window.cancelAnimationFrame(this.nextFrameID),this.nextFrameID=-1):clearTimeout(this._nextTimeout)},l(e,[{key:"scrollPosition",get:function(){return this.getScrollPosition()}},{key:"directionY",get:function(){return!this._canScrollY||0===this.speedY&&!this._scrolling?this._directionY=e.direction.none:this.speedY>0?this._directionY=e.direction.up:this.speedY<0&&(this._directionY=e.direction.down),this._directionY}},{key:"directionX",get:function(){return!this._canScrollX||0===this.speedX&&!this._scrolling?this._directionX=e.direction.none:this.speedX>0?this._directionX=e.direction.left:this.speedX<0&&(this._directionX=e.direction.right),this._directionX}},{key:"scrollTarget",get:function(){return this._scrollTarget}},{key:"scrolling",get:function(){return this._scrolling}},{key:"speedY",get:function(){return this._speedY}},{key:"speedX",get:function(){return this._speedX}},{key:"canScrollY",get:function(){return this._canScrollY}},{key:"canScrollX",get:function(){return this._canScrollX}},{key:"y",get:function(){return this.scrollPosition.y}},{key:"x",get:function(){return this.scrollPosition.x}},{key:"clientHeight",get:function(){return this._scrollTarget===window?window.innerHeight:this._scrollTarget.clientHeight}},{key:"clientWidth",get:function(){return this._scrollTarget===window?window.innerWidth:this._scrollTarget.clientWidth}},{key:"scrollHeight",get:function(){return this._scrollTarget===window?e.documentHeight:this._scrollTarget.scrollHeight}},{key:"scrollWidth",get:function(){return this._scrollTarget===window?e.documentWidth:this._scrollTarget.scrollWidth}}]),e}(c.default);p.direction={up:-1,down:1,none:0,right:2,left:-2},p.events={SCROLL_PROGRESS:"scroll:progress",SCROLL_START:"scroll:start",SCROLL_STOP:"scroll:stop",SCROLL_DOWN:"scroll:down",SCROLL_UP:"scroll:up",SCROLL_MIN:"scroll:min",SCROLL_MAX:"scroll:max",SCROLL_RESIZE:"scroll:resize"},e.default=p;var f=null,g=function(){function t(){n(this,t)}return l(t,null,[{key:"animationFrame",get:function(){return null===f&&(f=!!(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame)),f}}]),t}();t.exports=e.default}])});