/*! * perfect-scrollbar v1.5.3 * Copyright 2021 Hyunje Jun, MDBootstrap and Contributors * Licensed under MIT */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).PerfectScrollbar=e()}(this,(function(){"use strict";var t=Math.abs,e=Math.floor;function i(t){return getComputedStyle(t)}function r(t,e){for(var i in e){var r=e[i];"number"==typeof r&&(r+="px"),t.style[i]=r}return t}function n(t){var e=document.createElement("div");return e.className=t,e}function l(t,e){if(!Y)throw new Error("No element matching method supported");return Y.call(t,e)}function o(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function s(t,e){return Array.prototype.filter.call(t.children,(function(t){return l(t,e)}))}function a(t,e){var i=t.element.classList,r=X.state.scrolling(e);i.contains(r)?clearTimeout(w[e]):i.add(r)}function c(t,e){w[e]=setTimeout((function(){return t.isAlive&&t.element.classList.remove(X.state.scrolling(e))}),t.settings.scrollingThreshold)}function h(t,e){a(t,e),c(t,e)}function u(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,i,r,n){var l;if(void 0===r&&(r=!0),void 0===n&&(n=!1),"top"===e)l=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");l=["contentWidth","containerWidth","scrollLeft","x","left","right"]}!function(t,e,i,r,n){var l=i[0],o=i[1],s=i[2],a=i[3],c=i[4],d=i[5];void 0===r&&(r=!0),void 0===n&&(n=!1);var f=t.element;t.reach[a]=null,1>f[s]&&(t.reach[a]="start"),f[s]>t[l]-t[o]-1&&(t.reach[a]="end"),e&&(f.dispatchEvent(u("ps-scroll-"+a)),0>e?f.dispatchEvent(u("ps-scroll-"+c)):0=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),v(r,t),t.scrollbarXActive?r.classList.add(X.state.active("x")):(r.classList.remove(X.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,r.scrollLeft=!0===t.isRtl?t.contentWidth:0),t.scrollbarYActive?r.classList.add(X.state.active("y")):(r.classList.remove(X.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,r.scrollTop=0)}function g(t,e){var i=Math.min,r=Math.max;return t.settings.minScrollbarLength&&(e=r(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=i(e,t.settings.maxScrollbarLength)),e}function v(t,i){var n={width:i.railXWidth},l=e(t.scrollTop);n.left=i.isRtl?i.negativeScrollAdjustment+t.scrollLeft+i.containerWidth-i.contentWidth:t.scrollLeft,i.isScrollbarXUsingBottom?n.bottom=i.scrollbarXBottom-l:n.top=i.scrollbarXTop+l,r(i.scrollbarXRail,n);var o={top:l,height:i.railYHeight};i.isScrollbarYUsingRight?i.isRtl?o.right=i.contentWidth-(i.negativeScrollAdjustment+t.scrollLeft)-i.scrollbarYRight-i.scrollbarYOuterWidth-9:o.right=i.scrollbarYRight-t.scrollLeft:i.isRtl?o.left=i.negativeScrollAdjustment+t.scrollLeft+2*i.containerWidth-i.contentWidth-i.scrollbarYLeft-i.scrollbarYOuterWidth:o.left=i.scrollbarYLeft+t.scrollLeft,r(i.scrollbarYRail,o),r(i.scrollbarX,{left:i.scrollbarXLeft,width:i.scrollbarXWidth-i.railBorderXWidth}),r(i.scrollbarY,{top:i.scrollbarYTop,height:i.scrollbarYHeight-i.railBorderYWidth})}function m(t,e){function i(e){e.touches&&e.touches[0]&&(e[s]=e.touches[0].pageY),v[f]=m+w*(e[s]-Y),a(t,p),b(t),e.stopPropagation(),e.type.startsWith("touch")&&1t.scrollbarYTop?1:-1;t.element.scrollTop+=i*t.containerHeight,b(t),e.stopPropagation()})),t.event.bind(t.scrollbarX,"mousedown",(function(t){return t.stopPropagation()})),t.event.bind(t.scrollbarXRail,"mousedown",(function(e){var i=e.pageX-window.pageXOffset-t.scrollbarXRail.getBoundingClientRect().left>t.scrollbarXLeft?1:-1;t.element.scrollLeft+=i*t.containerWidth,b(t),e.stopPropagation()}))},"drag-thumb":function(t){m(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x","scrollbarXRail"]),m(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y","scrollbarYRail"])},keyboard:function(t){var i=t.element,r=function(){return l(i,":hover")},n=function(){return l(t.scrollbarX,":focus")||l(t.scrollbarY,":focus")};t.event.bind(t.ownerDocument,"keydown",(function(l){if(!(l.isDefaultPrevented&&l.isDefaultPrevented()||l.defaultPrevented)&&(r()||n())){var o=document.activeElement?document.activeElement:t.ownerDocument.activeElement;if(o){if("IFRAME"===o.tagName)o=o.contentDocument.activeElement;else for(;o.shadowRoot;)o=o.shadowRoot.activeElement;if(p(o))return}var s=0,a=0;switch(l.which){case 37:s=l.metaKey?-t.contentWidth:l.altKey?-t.containerWidth:-30;break;case 38:a=l.metaKey?t.contentHeight:l.altKey?t.containerHeight:30;break;case 39:s=l.metaKey?t.contentWidth:l.altKey?t.containerWidth:30;break;case 40:a=l.metaKey?-t.contentHeight:l.altKey?-t.containerHeight:-30;break;case 32:a=l.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||(i.scrollTop-=a,i.scrollLeft+=s,b(t),function(r,n){var l=e(i.scrollTop);if(0===r){if(!t.scrollbarYActive)return!1;if(0===l&&0=t.contentHeight-t.containerHeight&&0>n)return!t.settings.wheelPropagation}var o=i.scrollLeft;if(0===n){if(!t.scrollbarXActive)return!1;if(0===o&&0>r||o>=t.contentWidth-t.containerWidth&&0r||n.scrollTope||n.scrollLeftt(i)?s||a:c||h)||!r.settings.wheelPropagation}(s,a),c&&!i.ctrlKey&&(i.stopPropagation(),i.preventDefault())}}var o=r.element;void 0===window.onwheel?void 0!==window.onmousewheel&&r.event.bind(o,"mousewheel",l):r.event.bind(o,"wheel",l)},touch:function(r){function n(i,n){var l=e(d.scrollTop),o=d.scrollLeft,s=t(i),a=t(n);if(a>s){if(0>n&&l===r.contentHeight-r.containerHeight||0a&&(0>i&&o===r.contentWidth-r.containerWidth||0r||n.scrollTope||n.scrollLeftt(g.x)&&.01>t(g.y)?void clearInterval(v):r.element?(l(30*g.x,30*g.y),g.x*=.8,void(g.y*=.8)):void clearInterval(v):void clearInterval(v)}),10))}if(R.supportsTouch||R.supportsIePointer){var d=r.element,f={},p=0,g={},v=null;R.supportsTouch?(r.event.bind(d,"touchstart",a),r.event.bind(d,"touchmove",h),r.event.bind(d,"touchend",u)):R.supportsIePointer&&(window.PointerEvent?(r.event.bind(d,"pointerdown",a),r.event.bind(d,"pointermove",h),r.event.bind(d,"pointerup",u)):window.MSPointerEvent&&(r.event.bind(d,"MSPointerDown",a),r.event.bind(d,"MSPointerMove",h),r.event.bind(d,"MSPointerUp",u)))}}},H=function(t,l){var o=this;if(void 0===l&&(l={}),"string"==typeof t&&(t=document.querySelector(t)),!t||!t.nodeName)throw new Error("no element is specified to initialize PerfectScrollbar");for(var s in this.element=t,t.classList.add(X.main),this.settings={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},l)this.settings[s]=l[s];this.containerWidth=null,this.containerHeight=null,this.contentWidth=null,this.contentHeight=null;var a=function(){return t.classList.add(X.state.focus)},c=function(){return t.classList.remove(X.state.focus)};this.isRtl="rtl"===i(t).direction,!0===this.isRtl&&t.classList.add(X.rtl),this.isNegativeScroll=function(){var e,i=t.scrollLeft;return t.scrollLeft=-1,e=0>t.scrollLeft,t.scrollLeft=i,e}(),this.negativeScrollAdjustment=this.isNegativeScroll?t.scrollWidth-t.clientWidth:0,this.event=new L,this.ownerDocument=t.ownerDocument||document,this.scrollbarXRail=n(X.element.rail("x")),t.appendChild(this.scrollbarXRail),this.scrollbarX=n(X.element.thumb("x")),this.scrollbarXRail.appendChild(this.scrollbarX),this.scrollbarX.setAttribute("tabindex",0),this.event.bind(this.scrollbarX,"focus",a),this.event.bind(this.scrollbarX,"blur",c),this.scrollbarXActive=null,this.scrollbarXWidth=null,this.scrollbarXLeft=null;var h=i(this.scrollbarXRail);this.scrollbarXBottom=parseInt(h.bottom,10),isNaN(this.scrollbarXBottom)?(this.isScrollbarXUsingBottom=!1,this.scrollbarXTop=f(h.top)):this.isScrollbarXUsingBottom=!0,this.railBorderXWidth=f(h.borderLeftWidth)+f(h.borderRightWidth),r(this.scrollbarXRail,{display:"block"}),this.railXMarginWidth=f(h.marginLeft)+f(h.marginRight),r(this.scrollbarXRail,{display:""}),this.railXWidth=null,this.railXRatio=null,this.scrollbarYRail=n(X.element.rail("y")),t.appendChild(this.scrollbarYRail),this.scrollbarY=n(X.element.thumb("y")),this.scrollbarYRail.appendChild(this.scrollbarY),this.scrollbarY.setAttribute("tabindex",0),this.event.bind(this.scrollbarY,"focus",a),this.event.bind(this.scrollbarY,"blur",c),this.scrollbarYActive=null,this.scrollbarYHeight=null,this.scrollbarYTop=null;var u=i(this.scrollbarYRail);this.scrollbarYRight=parseInt(u.right,10),isNaN(this.scrollbarYRight)?(this.isScrollbarYUsingRight=!1,this.scrollbarYLeft=f(u.left)):this.isScrollbarYUsingRight=!0,this.scrollbarYOuterWidth=this.isRtl?function(t){var e=i(t);return f(e.width)+f(e.paddingLeft)+f(e.paddingRight)+f(e.borderLeftWidth)+f(e.borderRightWidth)}(this.scrollbarY):null,this.railBorderYWidth=f(u.borderTopWidth)+f(u.borderBottomWidth),r(this.scrollbarYRail,{display:"block"}),this.railYMarginHeight=f(u.marginTop)+f(u.marginBottom),r(this.scrollbarYRail,{display:""}),this.railYHeight=null,this.railYRatio=null,this.reach={x:0>=t.scrollLeft?"start":t.scrollLeft>=this.contentWidth-this.containerWidth?"end":null,y:0>=t.scrollTop?"start":t.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach((function(t){return T[t](o)})),this.lastScrollTop=e(t.scrollTop),this.lastScrollLeft=t.scrollLeft,this.event.bind(this.element,"scroll",(function(t){return o.onScroll(t)})),b(this)};return H.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,r(this.scrollbarXRail,{display:"block"}),r(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=f(i(this.scrollbarXRail).marginLeft)+f(i(this.scrollbarXRail).marginRight),this.railYMarginHeight=f(i(this.scrollbarYRail).marginTop)+f(i(this.scrollbarYRail).marginBottom),r(this.scrollbarXRail,{display:"none"}),r(this.scrollbarYRail,{display:"none"}),b(this),d(this,"top",0,!1,!0),d(this,"left",0,!1,!0),r(this.scrollbarXRail,{display:""}),r(this.scrollbarYRail,{display:""}))},H.prototype.onScroll=function(){this.isAlive&&(b(this),d(this,"top",this.element.scrollTop-this.lastScrollTop),d(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=e(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)},H.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),o(this.scrollbarX),o(this.scrollbarY),o(this.scrollbarXRail),o(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},H.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter((function(t){return!t.match(/^ps([-_].+|)$/)})).join(" ")},H}));