UNPKG

react-perfect-scrollbar

Version:
7 lines 24.8 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define("react-perfect-scrollbar",["react","prop-types"],e):"object"==typeof exports?exports["react-perfect-scrollbar"]=e(require("react"),require("prop-types")):t["react-perfect-scrollbar"]=e(t.React,t.PropTypes)}("undefined"!=typeof self?self:this,function(t,e){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){n(1),t.exports=n(6)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),o=function(t){return t&&t.__esModule?t:{default:t}}(r);e.default=o.default,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function o(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),h=n(3),u=r(h),p=n(4),d=n(5),f=r(d),v={"ps-scroll-y":"onScrollY","ps-scroll-x":"onScrollX","ps-scroll-up":"onScrollUp","ps-scroll-down":"onScrollDown","ps-scroll-left":"onScrollLeft","ps-scroll-right":"onScrollRight","ps-y-reach-start":"onYReachStart","ps-y-reach-end":"onYReachEnd","ps-x-reach-start":"onXReachStart","ps-x-reach-end":"onXReachEnd"};Object.freeze(v);var b=function(t){function e(t){i(this,e);var n=l(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return n.handleRef=n.handleRef.bind(n),n._handlerByEvent={},n}return s(e,t),c(e,[{key:"componentDidMount",value:function(){this.props.option&&console.warn('react-perfect-scrollbar: the "option" prop has been deprecated in favor of "options"'),this._ps=new f.default(this._container,this.props.options||this.props.option),this._updateEventHook(),this._updateClassName()}},{key:"componentDidUpdate",value:function(t){this._updateEventHook(t),this.updateScroll(),t.className!==this.props.className&&this._updateClassName()}},{key:"componentWillUnmount",value:function(){var t=this;Object.keys(this._handlerByEvent).forEach(function(e){var n=t._handlerByEvent[e];n&&t._container.removeEventListener(e,n,!1)}),this._handlerByEvent={},this._ps.destroy(),this._ps=null}},{key:"_updateEventHook",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.keys(v).forEach(function(n){var r=t.props[v[n]],o=e[v[n]];if(r!==o){if(o){var i=t._handlerByEvent[n];t._container.removeEventListener(n,i,!1),t._handlerByEvent[n]=null}if(r){var l=function(){return r(t._container)};t._container.addEventListener(n,l,!1),t._handlerByEvent[n]=l}}})}},{key:"_updateClassName",value:function(){var t=this.props.className,e=this._container.className.split(" ").filter(function(t){return t.match(/^ps([-_].+|)$/)}).join(" ");this._container&&(this._container.className="scrollbar-container"+(t?" "+t:"")+(e?" "+e:""))}},{key:"updateScroll",value:function(){this.props.onSync(this._ps)}},{key:"handleRef",value:function(t){this._container=t,this.props.containerRef(t)}},{key:"render",value:function(){var t=this.props,e=(t.className,t.style),n=(t.option,t.options,t.containerRef,t.onScrollY,t.onScrollX,t.onScrollUp,t.onScrollDown,t.onScrollLeft,t.onScrollRight,t.onYReachStart,t.onYReachEnd,t.onXReachStart,t.onXReachEnd,t.component),r=(t.onSync,t.children),i=o(t,["className","style","option","options","containerRef","onScrollY","onScrollX","onScrollUp","onScrollDown","onScrollLeft","onScrollRight","onYReachStart","onYReachEnd","onXReachStart","onXReachEnd","component","onSync","children"]),l=n;return u.default.createElement(l,a({style:e,ref:this.handleRef},i),r)}}]),e}(h.Component);e.default=b,b.defaultProps={className:"",style:void 0,option:void 0,options:void 0,containerRef:function(){},onScrollY:void 0,onScrollX:void 0,onScrollUp:void 0,onScrollDown:void 0,onScrollLeft:void 0,onScrollRight:void 0,onYReachStart:void 0,onYReachEnd:void 0,onXReachStart:void 0,onXReachEnd:void 0,onSync:function(t){return t.update()},component:"div"},b.propTypes={children:p.PropTypes.node.isRequired,className:p.PropTypes.string,style:p.PropTypes.object,option:p.PropTypes.object,options:p.PropTypes.object,containerRef:p.PropTypes.func,onScrollY:p.PropTypes.func,onScrollX:p.PropTypes.func,onScrollUp:p.PropTypes.func,onScrollDown:p.PropTypes.func,onScrollLeft:p.PropTypes.func,onScrollRight:p.PropTypes.func,onYReachStart:p.PropTypes.func,onYReachEnd:p.PropTypes.func,onXReachStart:p.PropTypes.func,onXReachEnd:p.PropTypes.func,onSync:p.PropTypes.func,component:p.PropTypes.string},t.exports=e.default},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){"use strict";/*! * perfect-scrollbar v1.5.0 * Copyright 2020 Hyunje Jun, MDBootstrap and Contributors * Licensed under MIT */ function r(t){return getComputedStyle(t)}function o(t,e){for(var n in e){var r=e[n];"number"==typeof r&&(r+="px"),t.style[n]=r}return t}function i(t){var e=document.createElement("div");return e.className=t,e}function l(t,e){if(!E)throw new Error("No element matching method supported");return E.call(t,e)}function s(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function a(t,e){return Array.prototype.filter.call(t.children,function(t){return l(t,e)})}function c(t,e){var n=t.element.classList,r=L.state.scrolling(e);n.contains(r)?clearTimeout(H[e]):n.add(r)}function h(t,e){H[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(L.state.scrolling(e))},t.settings.scrollingThreshold)}function u(t,e){c(t,e),h(t,e)}function p(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}function d(t,e,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=!1);var i;if("top"===e)i=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");i=["contentWidth","containerWidth","scrollLeft","x","left","right"]}f(t,n,i,r,o)}function f(t,e,n,r,o){var i=n[0],l=n[1],s=n[2],a=n[3],c=n[4],h=n[5];void 0===r&&(r=!0),void 0===o&&(o=!1);var d=t.element;t.reach[a]=null,d[s]<1&&(t.reach[a]="start"),d[s]>t[i]-t[l]-1&&(t.reach[a]="end"),e&&(d.dispatchEvent(p("ps-scroll-"+a)),e<0?d.dispatchEvent(p("ps-scroll-"+c)):e>0&&d.dispatchEvent(p("ps-scroll-"+h)),r&&u(t,a)),t.reach[a]&&(e||o)&&d.dispatchEvent(p("ps-"+a+"-reach-"+t.reach[a]))}function v(t){return parseInt(t,10)||0}function b(t){return l(t,"input,[contenteditable]")||l(t,"select,[contenteditable]")||l(t,"textarea,[contenteditable]")||l(t,"button,[contenteditable]")}function g(t){var e=r(t);return v(e.width)+v(e.paddingLeft)+v(e.paddingRight)+v(e.borderLeftWidth)+v(e.borderRightWidth)}function m(t){var e=t.element,n=Math.floor(e.scrollTop),r=e.getBoundingClientRect();t.containerWidth=Math.ceil(r.width),t.containerHeight=Math.ceil(r.height),t.contentWidth=e.scrollWidth,t.contentHeight=e.scrollHeight,e.contains(t.scrollbarXRail)||(a(e,L.element.rail("x")).forEach(function(t){return s(t)}),e.appendChild(t.scrollbarXRail)),e.contains(t.scrollbarYRail)||(a(e,L.element.rail("y")).forEach(function(t){return s(t)}),e.appendChild(t.scrollbarYRail)),!t.settings.suppressScrollX&&t.containerWidth+t.settings.scrollXMarginOffset<t.contentWidth?(t.scrollbarXActive=!0,t.railXWidth=t.containerWidth-t.railXMarginWidth,t.railXRatio=t.containerWidth/t.railXWidth,t.scrollbarXWidth=y(t,v(t.railXWidth*t.containerWidth/t.contentWidth)),t.scrollbarXLeft=v((t.negativeScrollAdjustment+e.scrollLeft)*(t.railXWidth-t.scrollbarXWidth)/(t.contentWidth-t.containerWidth))):t.scrollbarXActive=!1,!t.settings.suppressScrollY&&t.containerHeight+t.settings.scrollYMarginOffset<t.contentHeight?(t.scrollbarYActive=!0,t.railYHeight=t.containerHeight-t.railYMarginHeight,t.railYRatio=t.containerHeight/t.railYHeight,t.scrollbarYHeight=y(t,v(t.railYHeight*t.containerHeight/t.contentHeight)),t.scrollbarYTop=v(n*(t.railYHeight-t.scrollbarYHeight)/(t.contentHeight-t.containerHeight))):t.scrollbarYActive=!1,t.scrollbarXLeft>=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),Y(e,t),t.scrollbarXActive?e.classList.add(L.state.active("x")):(e.classList.remove(L.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=!0===t.isRtl?t.contentWidth:0),t.scrollbarYActive?e.classList.add(L.state.active("y")):(e.classList.remove(L.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)}function y(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function Y(t,e){var n={width:e.railXWidth},r=Math.floor(t.scrollTop);e.isRtl?n.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth-e.contentWidth:n.left=t.scrollLeft,e.isScrollbarXUsingBottom?n.bottom=e.scrollbarXBottom-r:n.top=e.scrollbarXTop+r,o(e.scrollbarXRail,n);var i={top:r,height:e.railYHeight};e.isScrollbarYUsingRight?e.isRtl?i.right=e.contentWidth-(e.negativeScrollAdjustment+t.scrollLeft)-e.scrollbarYRight-e.scrollbarYOuterWidth-9:i.right=e.scrollbarYRight-t.scrollLeft:e.isRtl?i.left=e.negativeScrollAdjustment+t.scrollLeft+2*e.containerWidth-e.contentWidth-e.scrollbarYLeft-e.scrollbarYOuterWidth:i.left=e.scrollbarYLeft+t.scrollLeft,o(e.scrollbarYRail,i),o(e.scrollbarX,{left:e.scrollbarXLeft,width:e.scrollbarXWidth-e.railBorderXWidth}),o(e.scrollbarY,{top:e.scrollbarYTop,height:e.scrollbarYHeight-e.railBorderYWidth})}function w(t){t.element;t.event.bind(t.scrollbarY,"mousedown",function(t){return t.stopPropagation()}),t.event.bind(t.scrollbarYRail,"mousedown",function(e){var n=e.pageY-window.pageYOffset-t.scrollbarYRail.getBoundingClientRect().top,r=n>t.scrollbarYTop?1:-1;t.element.scrollTop+=r*t.containerHeight,m(t),e.stopPropagation()}),t.event.bind(t.scrollbarX,"mousedown",function(t){return t.stopPropagation()}),t.event.bind(t.scrollbarXRail,"mousedown",function(e){var n=e.pageX-window.pageXOffset-t.scrollbarXRail.getBoundingClientRect().left,r=n>t.scrollbarXLeft?1:-1;t.element.scrollLeft+=r*t.containerWidth,m(t),e.stopPropagation()})}function X(t){R(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x","scrollbarXRail"]),R(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y","scrollbarYRail"])}function R(t,e){function n(e){e.touches&&e.touches[0]&&(e[s]=e.touches[0].pageY),b[d]=g+Y*(e[s]-y),c(t,f),m(t),e.stopPropagation(),e.preventDefault()}function r(){h(t,f),t[v].classList.remove(L.state.clicking),t.event.unbind(t.ownerDocument,"mousemove",n)}function o(e,o){g=b[d],o&&e.touches&&(e[s]=e.touches[0].pageY),y=e[s],Y=(t[l]-t[i])/(t[a]-t[p]),o?t.event.bind(t.ownerDocument,"touchmove",n):(t.event.bind(t.ownerDocument,"mousemove",n),t.event.once(t.ownerDocument,"mouseup",r),e.preventDefault()),t[v].classList.add(L.state.clicking),e.stopPropagation()}var i=e[0],l=e[1],s=e[2],a=e[3],u=e[4],p=e[5],d=e[6],f=e[7],v=e[8],b=t.element,g=null,y=null,Y=null;t.event.bind(t[u],"mousedown",function(t){o(t)}),t.event.bind(t[u],"touchstart",function(t){o(t,!0)})}function S(t){function e(e,r){var o=Math.floor(n.scrollTop);if(0===e){if(!t.scrollbarYActive)return!1;if(0===o&&r>0||o>=t.contentHeight-t.containerHeight&&r<0)return!t.settings.wheelPropagation}var i=n.scrollLeft;if(0===r){if(!t.scrollbarXActive)return!1;if(0===i&&e<0||i>=t.contentWidth-t.containerWidth&&e>0)return!t.settings.wheelPropagation}return!0}var n=t.element,r=function(){return l(n,":hover")},o=function(){return l(t.scrollbarX,":focus")||l(t.scrollbarY,":focus")};t.event.bind(t.ownerDocument,"keydown",function(i){if(!(i.isDefaultPrevented&&i.isDefaultPrevented()||i.defaultPrevented)&&(r()||o())){var l=document.activeElement?document.activeElement:t.ownerDocument.activeElement;if(l){if("IFRAME"===l.tagName)l=l.contentDocument.activeElement;else for(;l.shadowRoot;)l=l.shadowRoot.activeElement;if(b(l))return}var s=0,a=0;switch(i.which){case 37:s=i.metaKey?-t.contentWidth:i.altKey?-t.containerWidth:-30;break;case 38:a=i.metaKey?t.contentHeight:i.altKey?t.containerHeight:30;break;case 39:s=i.metaKey?t.contentWidth:i.altKey?t.containerWidth:30;break;case 40:a=i.metaKey?-t.contentHeight:i.altKey?-t.containerHeight:-30;break;case 32:a=i.shiftKey?t.containerHeight:-t.containerHeight;break;case 33:a=t.containerHeight;break;case 34:a=-t.containerHeight;break;case 36:a=t.contentHeight;break;case 35:a=-t.contentHeight;break;default:return}t.settings.suppressScrollX&&0!==s||t.settings.suppressScrollY&&0!==a||(n.scrollTop-=a,n.scrollLeft+=s,m(t),e(s,a)&&i.preventDefault())}})}function T(t){function e(e,n){var r=Math.floor(l.scrollTop),o=0===l.scrollTop,i=r+l.offsetHeight===l.scrollHeight,s=0===l.scrollLeft,a=l.scrollLeft+l.offsetWidth===l.scrollWidth;return!(Math.abs(n)>Math.abs(e)?o||i:s||a)||!t.settings.wheelPropagation}function n(t){var e=t.deltaX,n=-1*t.deltaY;return void 0!==e&&void 0!==n||(e=-1*t.wheelDeltaX/6,n=t.wheelDeltaY/6),t.deltaMode&&1===t.deltaMode&&(e*=10,n*=10),e!==e&&n!==n&&(e=0,n=t.wheelDelta),t.shiftKey?[-n,-e]:[e,n]}function o(t,e,n){if(!M.isWebKit&&l.querySelector("select:focus"))return!0;if(!l.contains(t))return!1;for(var o=t;o&&o!==l;){if(o.classList.contains(L.element.consuming))return!0;var i=r(o);if(n&&i.overflowY.match(/(scroll|auto)/)){var s=o.scrollHeight-o.clientHeight;if(s>0&&(o.scrollTop>0&&n<0||o.scrollTop<s&&n>0))return!0}if(e&&i.overflowX.match(/(scroll|auto)/)){var a=o.scrollWidth-o.clientWidth;if(a>0&&(o.scrollLeft>0&&e<0||o.scrollLeft<a&&e>0))return!0}o=o.parentNode}return!1}function i(r){var i=n(r),s=i[0],a=i[1];if(!o(r.target,s,a)){var c=!1;t.settings.useBothWheelAxes?t.scrollbarYActive&&!t.scrollbarXActive?(a?l.scrollTop-=a*t.settings.wheelSpeed:l.scrollTop+=s*t.settings.wheelSpeed,c=!0):t.scrollbarXActive&&!t.scrollbarYActive&&(s?l.scrollLeft+=s*t.settings.wheelSpeed:l.scrollLeft-=a*t.settings.wheelSpeed,c=!0):(l.scrollTop-=a*t.settings.wheelSpeed,l.scrollLeft+=s*t.settings.wheelSpeed),m(t),c=c||e(s,a),c&&!r.ctrlKey&&(r.stopPropagation(),r.preventDefault())}}var l=t.element;void 0!==window.onwheel?t.event.bind(l,"wheel",i):void 0!==window.onmousewheel&&t.event.bind(l,"mousewheel",i)}function W(t){function e(e,n){var r=Math.floor(h.scrollTop),o=h.scrollLeft,i=Math.abs(e),l=Math.abs(n);if(l>i){if(n<0&&r===t.contentHeight-t.containerHeight||n>0&&0===r)return 0===window.scrollY&&n>0&&M.isChrome}else if(i>l&&(e<0&&o===t.contentWidth-t.containerWidth||e>0&&0===o))return!0;return!0}function n(e,n){h.scrollTop-=n,h.scrollLeft-=e,m(t)}function o(t){return t.targetTouches?t.targetTouches[0]:t}function i(t){return(!t.pointerType||"pen"!==t.pointerType||0!==t.buttons)&&(!(!t.targetTouches||1!==t.targetTouches.length)||!(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE))}function l(t){if(i(t)){var e=o(t);u.pageX=e.pageX,u.pageY=e.pageY,p=(new Date).getTime(),null!==f&&clearInterval(f)}}function s(t,e,n){if(!h.contains(t))return!1;for(var o=t;o&&o!==h;){if(o.classList.contains(L.element.consuming))return!0;var i=r(o);if(n&&i.overflowY.match(/(scroll|auto)/)){var l=o.scrollHeight-o.clientHeight;if(l>0&&(o.scrollTop>0&&n<0||o.scrollTop<l&&n>0))return!0}if(e&&i.overflowX.match(/(scroll|auto)/)){var s=o.scrollWidth-o.clientWidth;if(s>0&&(o.scrollLeft>0&&e<0||o.scrollLeft<s&&e>0))return!0}o=o.parentNode}return!1}function a(t){if(i(t)){var r=o(t),l={pageX:r.pageX,pageY:r.pageY},a=l.pageX-u.pageX,c=l.pageY-u.pageY;if(s(t.target,a,c))return;n(a,c),u=l;var h=(new Date).getTime(),f=h-p;f>0&&(d.x=a/f,d.y=c/f,p=h),e(a,c)&&t.preventDefault()}}function c(){t.settings.swipeEasing&&(clearInterval(f),f=setInterval(function(){return t.isInitialized?void clearInterval(f):d.x||d.y?Math.abs(d.x)<.01&&Math.abs(d.y)<.01?void clearInterval(f):(n(30*d.x,30*d.y),d.x*=.8,void(d.y*=.8)):void clearInterval(f)},10))}if(M.supportsTouch||M.supportsIePointer){var h=t.element,u={},p=0,d={},f=null;M.supportsTouch?(t.event.bind(h,"touchstart",l),t.event.bind(h,"touchmove",a),t.event.bind(h,"touchend",c)):M.supportsIePointer&&(window.PointerEvent?(t.event.bind(h,"pointerdown",l),t.event.bind(h,"pointermove",a),t.event.bind(h,"pointerup",c)):window.MSPointerEvent&&(t.event.bind(h,"MSPointerDown",l),t.event.bind(h,"MSPointerMove",a),t.event.bind(h,"MSPointerUp",c)))}}Object.defineProperty(e,"__esModule",{value:!0});var E="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector),L={main:"ps",rtl:"ps__rtl",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",clicking:"ps--clicking",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},H={x:null,y:null},P=function(t){this.element=t,this.handlers={}},_={isEmpty:{configurable:!0}};P.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addEventListener(t,e,!1)},P.prototype.unbind=function(t,e){var n=this;this.handlers[t]=this.handlers[t].filter(function(r){return!(!e||r===e)||(n.element.removeEventListener(t,r,!1),!1)})},P.prototype.unbindAll=function(){for(var t in this.handlers)this.unbind(t)},_.isEmpty.get=function(){var t=this;return Object.keys(this.handlers).every(function(e){return 0===t.handlers[e].length})},Object.defineProperties(P.prototype,_);var x=function(){this.eventElements=[]};x.prototype.eventElement=function(t){var e=this.eventElements.filter(function(e){return e.element===t})[0];return e||(e=new P(t),this.eventElements.push(e)),e},x.prototype.bind=function(t,e,n){this.eventElement(t).bind(e,n)},x.prototype.unbind=function(t,e,n){var r=this.eventElement(t);r.unbind(e,n),r.isEmpty&&this.eventElements.splice(this.eventElements.indexOf(r),1)},x.prototype.unbindAll=function(){this.eventElements.forEach(function(t){return t.unbindAll()}),this.eventElements=[]},x.prototype.once=function(t,e,n){var r=this.eventElement(t),o=function(t){r.unbind(e,o),n(t)};r.bind(e,o)};var M={isWebKit:"undefined"!=typeof document&&"WebkitAppearance"in document.documentElement.style,supportsTouch:"undefined"!=typeof window&&("ontouchstart"in window||"maxTouchPoints"in window.navigator&&window.navigator.maxTouchPoints>0||window.DocumentTouch&&document instanceof window.DocumentTouch),supportsIePointer:"undefined"!=typeof navigator&&navigator.msMaxTouchPoints,isChrome:"undefined"!=typeof navigator&&/Chrome/i.test(navigator&&navigator.userAgent)},k=function(){return{handlers:["click-rail","drag-thumb","keyboard","wheel","touch"],maxScrollbarLength:null,minScrollbarLength:null,scrollingThreshold:1e3,scrollXMarginOffset:0,scrollYMarginOffset:0,suppressScrollX:!1,suppressScrollY:!1,swipeEasing:!0,useBothWheelAxes:!1,wheelPropagation:!0,wheelSpeed:1}},A={"click-rail":w,"drag-thumb":X,keyboard:S,wheel:T,touch:W},O=function(t,e){var n=this;if(void 0===e&&(e={}),"string"==typeof t&&(t=document.querySelector(t)),!t||!t.nodeName)throw new Error("no element is specified to initialize PerfectScrollbar");this.element=t,t.classList.add(L.main),this.settings=k();for(var l in e)this.settings[l]=e[l];this.containerWidth=null,this.containerHeight=null,this.contentWidth=null,this.contentHeight=null;var s=function(){return t.classList.add(L.state.focus)},a=function(){return t.classList.remove(L.state.focus)};this.isRtl="rtl"===r(t).direction,!0===this.isRtl&&t.classList.add(L.rtl),this.isNegativeScroll=function(){var e=t.scrollLeft,n=null;return t.scrollLeft=-1,n=t.scrollLeft<0,t.scrollLeft=e,n}(),this.negativeScrollAdjustment=this.isNegativeScroll?t.scrollWidth-t.clientWidth:0,this.event=new x,this.ownerDocument=t.ownerDocument||document,this.scrollbarXRail=i(L.element.rail("x")),t.appendChild(this.scrollbarXRail),this.scrollbarX=i(L.element.thumb("x")),this.scrollbarXRail.appendChild(this.scrollbarX),this.scrollbarX.setAttribute("tabindex",0),this.event.bind(this.scrollbarX,"focus",s),this.event.bind(this.scrollbarX,"blur",a),this.scrollbarXActive=null,this.scrollbarXWidth=null,this.scrollbarXLeft=null;var c=r(this.scrollbarXRail);this.scrollbarXBottom=parseInt(c.bottom,10),isNaN(this.scrollbarXBottom)?(this.isScrollbarXUsingBottom=!1,this.scrollbarXTop=v(c.top)):this.isScrollbarXUsingBottom=!0,this.railBorderXWidth=v(c.borderLeftWidth)+v(c.borderRightWidth),o(this.scrollbarXRail,{display:"block"}),this.railXMarginWidth=v(c.marginLeft)+v(c.marginRight),o(this.scrollbarXRail,{display:""}),this.railXWidth=null,this.railXRatio=null,this.scrollbarYRail=i(L.element.rail("y")),t.appendChild(this.scrollbarYRail),this.scrollbarY=i(L.element.thumb("y")),this.scrollbarYRail.appendChild(this.scrollbarY),this.scrollbarY.setAttribute("tabindex",0),this.event.bind(this.scrollbarY,"focus",s),this.event.bind(this.scrollbarY,"blur",a),this.scrollbarYActive=null,this.scrollbarYHeight=null,this.scrollbarYTop=null;var h=r(this.scrollbarYRail);this.scrollbarYRight=parseInt(h.right,10),isNaN(this.scrollbarYRight)?(this.isScrollbarYUsingRight=!1,this.scrollbarYLeft=v(h.left)):this.isScrollbarYUsingRight=!0,this.scrollbarYOuterWidth=this.isRtl?g(this.scrollbarY):null,this.railBorderYWidth=v(h.borderTopWidth)+v(h.borderBottomWidth),o(this.scrollbarYRail,{display:"block"}),this.railYMarginHeight=v(h.marginTop)+v(h.marginBottom),o(this.scrollbarYRail,{display:""}),this.railYHeight=null,this.railYRatio=null,this.reach={x:t.scrollLeft<=0?"start":t.scrollLeft>=this.contentWidth-this.containerWidth?"end":null,y:t.scrollTop<=0?"start":t.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return A[t](n)}),this.lastScrollTop=Math.floor(t.scrollTop),this.lastScrollLeft=t.scrollLeft,this.event.bind(this.element,"scroll",function(t){return n.onScroll(t)}),m(this)};O.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,o(this.scrollbarXRail,{display:"block"}),o(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=v(r(this.scrollbarXRail).marginLeft)+v(r(this.scrollbarXRail).marginRight),this.railYMarginHeight=v(r(this.scrollbarYRail).marginTop)+v(r(this.scrollbarYRail).marginBottom),o(this.scrollbarXRail,{display:"none"}),o(this.scrollbarYRail,{display:"none"}),m(this),d(this,"top",0,!1,!0),d(this,"left",0,!1,!0),o(this.scrollbarXRail,{display:""}),o(this.scrollbarYRail,{display:""}))},O.prototype.onScroll=function(t){this.isAlive&&(m(this),d(this,"top",this.element.scrollTop-this.lastScrollTop),d(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=Math.floor(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)},O.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),s(this.scrollbarX),s(this.scrollbarY),s(this.scrollbarXRail),s(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},O.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")},e.default=O},function(t,e){}])}); //# sourceMappingURL=react-perfect-scrollbar.min.js.map