simplebar
Advanced tools
Comparing version 6.0.0-beta.9 to 6.0.0-beta.10
/** | ||
* simplebar - v6.0.0-beta.9 | ||
* simplebar - v6.0.0-beta.10 | ||
* Scrollbars, simpler. | ||
@@ -4,0 +4,0 @@ * https://grsmto.github.io/simplebar/ |
/** | ||
* simplebar - v6.0.0-beta.9 | ||
* simplebar - v6.0.0-beta.10 | ||
* Scrollbars, simpler. | ||
@@ -1406,3 +1406,3 @@ * https://grsmto.github.io/simplebar/ | ||
var dummyChildOffsetAfterScroll = SimpleBar.getOffset(dummyChild); | ||
scrollbarDummyEl.remove(); | ||
document.body.removeChild(scrollbarDummyEl); | ||
SimpleBar.rtlHelpers = { | ||
@@ -1409,0 +1409,0 @@ // determines if the scrolling is responding with negative values |
/** | ||
* simplebar - v6.0.0-beta.9 | ||
* simplebar - v6.0.0-beta.10 | ||
* Scrollbars, simpler. | ||
@@ -10,2 +10,2 @@ * https://grsmto.github.io/simplebar/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).SimpleBar=t()}(this,(function(){"use strict";var e=!("undefined"==typeof window||!window.document||!window.document.createElement);function t(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var r="object"==typeof global&&global&&global.Object===Object&&global,l="object"==typeof self&&self&&self.Object===Object&&self,o=r||l||Function("return this")(),n=o.Symbol,a=Object.prototype,c=a.hasOwnProperty,h=a.toString,d=n?n.toStringTag:void 0;var u=Object.prototype.toString;var f=n?n.toStringTag:void 0;function p(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":f&&f in Object(e)?function(e){var t=c.call(e,d),i=e[d];try{e[d]=void 0;var s=!0}catch(e){}var r=h.call(e);return s&&(t?e[d]=i:delete e[d]),r}(e):function(e){return u.call(e)}(e)}function v(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var m=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,b=/^0b[01]+$/i,x=/^0o[0-7]+$/i,y=parseInt;function E(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==p(e)}(e))return NaN;if(v(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=v(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(m,"");var i=b.test(e);return i||x.test(e)?y(e.slice(2),i?2:8):g.test(e)?NaN:+e}var O=function(){return o.Date.now()},w=Math.max,S=Math.min;function k(e,t,i){var s,r,l,o,n,a,c=0,h=!1,d=!1,u=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var i=s,l=r;return s=r=void 0,c=t,o=e.apply(l,i)}function p(e){return c=e,n=setTimeout(g,t),h?f(e):o}function m(e){var i=e-a;return void 0===a||i>=t||i<0||d&&e-c>=l}function g(){var e=O();if(m(e))return b(e);n=setTimeout(g,function(e){var i=t-(e-a);return d?S(i,l-(e-c)):i}(e))}function b(e){return n=void 0,u&&s?f(e):(s=r=void 0,o)}function x(){var e=O(),i=m(e);if(s=arguments,r=this,a=e,i){if(void 0===n)return p(a);if(d)return clearTimeout(n),n=setTimeout(g,t),f(a)}return void 0===n&&(n=setTimeout(g,t)),o}return t=E(t)||0,v(i)&&(h=!!i.leading,l=(d="maxWait"in i)?w(E(i.maxWait)||0,t):l,u="trailing"in i?!!i.trailing:u),x.cancel=function(){void 0!==n&&clearTimeout(n),c=0,s=a=r=n=void 0},x.flush=function(){return void 0===n?o:b(O())},x}function A(e,t,i){var s=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return v(i)&&(s="leading"in i?!!i.leading:s,r="trailing"in i?!!i.trailing:r),k(e,t,{leading:s,maxWait:t,trailing:r})}var L=null,M=null;function W(){if(null===L){if("undefined"==typeof document)return L=0;var e=document.body,t=document.createElement("div");t.classList.add("simplebar-hide-scrollbar"),e.appendChild(t);var i=t.getBoundingClientRect().right;e.removeChild(t),L=i}return L}function N(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window}function C(e){return e&&e.ownerDocument?e.ownerDocument:document}function z(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function T(e){for(var i=1;i<arguments.length;i++){var s=null!=arguments[i]?arguments[i]:{};i%2?z(Object(s),!0).forEach((function(i){t(e,i,s[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):z(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}e&&window.addEventListener("resize",(function(){M!==window.devicePixelRatio&&(M=window.devicePixelRatio,L=null)}));var D=function(){function t(e){var s=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.onScroll=function(){var e=N(s.el);s.scrollXTicking||(e.requestAnimationFrame(s.scrollX),s.scrollXTicking=!0),s.scrollYTicking||(e.requestAnimationFrame(s.scrollY),s.scrollYTicking=!0),s.isScrolling||(s.isScrolling=!0,s.el.classList.add(s.classNames.scrolling)),s.onStopScrolling()},this.scrollX=function(){s.axis.x.isOverflowing&&s.positionScrollbar("x"),s.scrollXTicking=!1},this.scrollY=function(){s.axis.y.isOverflowing&&s.positionScrollbar("y"),s.scrollYTicking=!1},this.onStopScrolling=function(){s.el.classList.remove(s.classNames.scrolling),s.isScrolling=!1},this.onMouseEnter=function(){s.isMouseEntering||(s.el.classList.add(s.classNames.mouseEntered),s.isMouseEntering=!0),s.onMouseEntered()},this.onMouseEntered=function(){s.el.classList.remove(s.classNames.mouseEntered),s.isMouseEntering=!1},this.onMouseMove=function(e){s.mouseX=e.clientX,s.mouseY=e.clientY,(s.axis.x.isOverflowing||s.axis.x.forceVisible)&&s.onMouseMoveForAxis("x"),(s.axis.y.isOverflowing||s.axis.y.forceVisible)&&s.onMouseMoveForAxis("y")},this.onMouseLeave=function(){s.onMouseMove.cancel(),(s.axis.x.isOverflowing||s.axis.x.forceVisible)&&s.onMouseLeaveForAxis("x"),(s.axis.y.isOverflowing||s.axis.y.forceVisible)&&s.onMouseLeaveForAxis("y"),s.mouseX=-1,s.mouseY=-1},this.onWindowResize=function(){s.scrollbarWidth=t.getScrollbarWidth(),s.hideNativeScrollbar()},this.onPointerEvent=function(e){var t,i;s.axis.x.track.rect=s.axis.x.track.el.getBoundingClientRect(),s.axis.y.track.rect=s.axis.y.track.el.getBoundingClientRect(),(s.axis.x.isOverflowing||s.axis.x.forceVisible)&&(t=s.isWithinBounds(s.axis.x.track.rect)),(s.axis.y.isOverflowing||s.axis.y.forceVisible)&&(i=s.isWithinBounds(s.axis.y.track.rect)),(t||i)&&(e.stopPropagation(),"pointerdown"===e.type&&"touch"!==e.pointerType&&(t&&(s.axis.x.scrollbar.rect=s.axis.x.scrollbar.el.getBoundingClientRect(),s.isWithinBounds(s.axis.x.scrollbar.rect)?s.onDragStart(e,"x"):s.onTrackClick(e,"x")),i&&(s.axis.y.scrollbar.rect=s.axis.y.scrollbar.el.getBoundingClientRect(),s.isWithinBounds(s.axis.y.scrollbar.rect)?s.onDragStart(e,"y"):s.onTrackClick(e,"y"))))},this.drag=function(e){var i=s.axis[s.draggedAxis].track,r=i.rect[s.axis[s.draggedAxis].sizeAttr],l=s.axis[s.draggedAxis].scrollbar,o=s.contentWrapperEl[s.axis[s.draggedAxis].scrollSizeAttr],n=parseInt(s.elStyles[s.axis[s.draggedAxis].sizeAttr],10);e.preventDefault(),e.stopPropagation();var a=(("y"===s.draggedAxis?e.pageY:e.pageX)-i.rect[s.axis[s.draggedAxis].offsetAttr]-s.axis[s.draggedAxis].dragOffset)/(r-l.size)*(o-n);"x"===s.draggedAxis&&(a=s.isRtl&&t.getRtlHelpers().isScrollOriginAtZero?a-(r+l.size):a),s.contentWrapperEl[s.axis[s.draggedAxis].scrollOffsetAttr]=a},this.onEndDrag=function(e){var t=C(s.el),i=N(s.el);e.preventDefault(),e.stopPropagation(),s.el.classList.remove(s.classNames.dragging),t.removeEventListener("mousemove",s.drag,!0),t.removeEventListener("mouseup",s.onEndDrag,!0),s.removePreventClickId=i.setTimeout((function(){t.removeEventListener("click",s.preventClick,!0),t.removeEventListener("dblclick",s.preventClick,!0),s.removePreventClickId=null}))},this.preventClick=function(e){e.preventDefault(),e.stopPropagation()},this.el=e,this.minScrollbarWidth=20,this.stopScrollDelay=175,this.options=T(T({},t.defaultOptions),r),this.classNames=T({contentEl:"simplebar-content",contentWrapper:"simplebar-content-wrapper",offset:"simplebar-offset",mask:"simplebar-mask",wrapper:"simplebar-wrapper",placeholder:"simplebar-placeholder",scrollbar:"simplebar-scrollbar",track:"simplebar-track",heightAutoObserverWrapperEl:"simplebar-height-auto-observer-wrapper",heightAutoObserverEl:"simplebar-height-auto-observer",visible:"simplebar-visible",horizontal:"simplebar-horizontal",vertical:"simplebar-vertical",hover:"simplebar-hover",dragging:"simplebar-dragging",scrolling:"simplebar-scrolling",scrollable:"simplebar-scrollable",mouseEntered:"simplebar-mouse-entered"},this.options.classNames),this.axis={x:{scrollOffsetAttr:"scrollLeft",sizeAttr:"width",scrollSizeAttr:"scrollWidth",offsetSizeAttr:"offsetWidth",offsetAttr:"left",overflowAttr:"overflowX",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}},y:{scrollOffsetAttr:"scrollTop",sizeAttr:"height",scrollSizeAttr:"scrollHeight",offsetSizeAttr:"offsetHeight",offsetAttr:"top",overflowAttr:"overflowY",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}}},this.removePreventClickId=null,this.isScrolling=!1,this.isMouseEntering=!1,t.instances.has(this.el)||(r.classNames&&console.warn("simplebar: classNames option is deprecated. Please override the styles with CSS instead."),r.autoHide&&console.warn("simplebar: autoHide option is deprecated. Please use CSS instead: '.simplebar-scrollbar::before { opacity: 0.5 };' for autoHide: false"),this.onMouseMove=A(this.onMouseMove,64),this.onWindowResize=k(this.onWindowResize,64,{leading:!0}),this.onStopScrolling=k(this.onStopScrolling,this.stopScrollDelay),this.onMouseEntered=k(this.onMouseEntered,this.stopScrollDelay),this.init())}var r,l,o;return r=t,o=[{key:"getRtlHelpers",value:function(){if(t.rtlHelpers)return t.rtlHelpers;var e=document.createElement("div");e.innerHTML='<div class="simplebar-dummy-scrollbar-size"><div></div></div>';var i=e.firstElementChild,s=i.firstElementChild;document.body.appendChild(i),i.scrollLeft=0;var r=t.getOffset(i),l=t.getOffset(s);i.scrollLeft=-999;var o=t.getOffset(s);return i.remove(),t.rtlHelpers={isScrollOriginAtZero:r.left!==l.left,isScrollingToNegative:l.left!==o.left},t.rtlHelpers}},{key:"getScrollbarWidth",value:function(){try{return"none"===getComputedStyle(this.contentWrapperEl,"::-webkit-scrollbar").display||"scrollbarWidth"in document.documentElement.style||"-ms-overflow-style"in document.documentElement.style?0:W()}catch(e){return W()}}},{key:"getOffset",value:function(e){var t=e.getBoundingClientRect(),i=C(e),s=N(e);return{top:t.top+(s.pageYOffset||i.documentElement.scrollTop),left:t.left+(s.pageXOffset||i.documentElement.scrollLeft)}}}],(l=[{key:"init",value:function(){t.instances.set(this.el,this),e&&(this.initDOM(),this.rtlHelpers=t.getRtlHelpers(),this.scrollbarWidth=t.getScrollbarWidth(),this.recalculate(),this.initListeners())}},{key:"initDOM",value:function(){var e=this;if(Array.prototype.filter.call(this.el.children,(function(t){return t.classList.contains(e.classNames.wrapper)})).length)this.wrapperEl=this.el.querySelector(".".concat(this.classNames.wrapper)),this.contentWrapperEl=this.options.scrollableNode||this.el.querySelector(".".concat(this.classNames.contentWrapper)),this.contentEl=this.options.contentNode||this.el.querySelector(".".concat(this.classNames.contentEl)),this.offsetEl=this.el.querySelector(".".concat(this.classNames.offset)),this.maskEl=this.el.querySelector(".".concat(this.classNames.mask)),this.placeholderEl=this.findChild(this.wrapperEl,".".concat(this.classNames.placeholder)),this.heightAutoObserverWrapperEl=this.el.querySelector(".".concat(this.classNames.heightAutoObserverWrapperEl)),this.heightAutoObserverEl=this.el.querySelector(".".concat(this.classNames.heightAutoObserverEl)),this.axis.x.track.el=this.findChild(this.el,".".concat(this.classNames.track,".").concat(this.classNames.horizontal)),this.axis.y.track.el=this.findChild(this.el,".".concat(this.classNames.track,".").concat(this.classNames.vertical));else{for(this.wrapperEl=document.createElement("div"),this.contentWrapperEl=document.createElement("div"),this.offsetEl=document.createElement("div"),this.maskEl=document.createElement("div"),this.contentEl=document.createElement("div"),this.placeholderEl=document.createElement("div"),this.heightAutoObserverWrapperEl=document.createElement("div"),this.heightAutoObserverEl=document.createElement("div"),this.wrapperEl.classList.add(this.classNames.wrapper),this.contentWrapperEl.classList.add(this.classNames.contentWrapper),this.offsetEl.classList.add(this.classNames.offset),this.maskEl.classList.add(this.classNames.mask),this.contentEl.classList.add(this.classNames.contentEl),this.placeholderEl.classList.add(this.classNames.placeholder),this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl),this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);this.el.firstChild;)this.contentEl.appendChild(this.el.firstChild);this.contentWrapperEl.appendChild(this.contentEl),this.offsetEl.appendChild(this.contentWrapperEl),this.maskEl.appendChild(this.offsetEl),this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl),this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl),this.wrapperEl.appendChild(this.maskEl),this.wrapperEl.appendChild(this.placeholderEl),this.el.appendChild(this.wrapperEl)}if(!this.axis.x.track.el||!this.axis.y.track.el){var t=document.createElement("div"),i=document.createElement("div");t.classList.add(this.classNames.track),i.classList.add(this.classNames.scrollbar),t.appendChild(i),this.axis.x.track.el=t.cloneNode(!0),this.axis.x.track.el.classList.add(this.classNames.horizontal),this.axis.y.track.el=t.cloneNode(!0),this.axis.y.track.el.classList.add(this.classNames.vertical),this.el.appendChild(this.axis.x.track.el),this.el.appendChild(this.axis.y.track.el)}this.axis.x.scrollbar.el=this.axis.x.track.el.querySelector(".".concat(this.classNames.scrollbar)),this.axis.y.scrollbar.el=this.axis.y.track.el.querySelector(".".concat(this.classNames.scrollbar)),this.options.autoHide||(this.axis.x.scrollbar.el.classList.add(this.classNames.visible),this.axis.y.scrollbar.el.classList.add(this.classNames.visible)),this.el.setAttribute("data-simplebar","init")}},{key:"initListeners",value:function(){var e=this,t=N(this.el);if(this.el.addEventListener("mouseenter",this.onMouseEnter),this.el.addEventListener("pointerdown",this.onPointerEvent,!0),this.el.addEventListener("mousemove",this.onMouseMove),this.el.addEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl.addEventListener("scroll",this.onScroll),t.addEventListener("resize",this.onWindowResize),window.ResizeObserver){var i=!1,s=t.ResizeObserver||ResizeObserver;this.resizeObserver=new s((function(){i&&t.requestAnimationFrame((function(){e.recalculate()}))})),this.resizeObserver.observe(this.el),this.resizeObserver.observe(this.contentEl),t.requestAnimationFrame((function(){i=!0}))}this.mutationObserver=new t.MutationObserver((function(){t.requestAnimationFrame((function(){e.recalculate()}))})),this.mutationObserver.observe(this.contentEl,{childList:!0,subtree:!0,characterData:!0})}},{key:"recalculate",value:function(){var e=N(this.el);this.elStyles=e.getComputedStyle(this.el),this.isRtl="rtl"===this.elStyles.direction;var t=this.contentEl.offsetWidth,i=this.heightAutoObserverEl.offsetHeight<=1,s=this.heightAutoObserverEl.offsetWidth<=1||t>0,r=this.contentWrapperEl.offsetWidth,l=this.elStyles.overflowX,o=this.elStyles.overflowY;this.contentEl.style.padding="".concat(this.elStyles.paddingTop," ").concat(this.elStyles.paddingRight," ").concat(this.elStyles.paddingBottom," ").concat(this.elStyles.paddingLeft),this.wrapperEl.style.margin="-".concat(this.elStyles.paddingTop," -").concat(this.elStyles.paddingRight," -").concat(this.elStyles.paddingBottom," -").concat(this.elStyles.paddingLeft);var n=this.contentEl.scrollHeight,a=this.contentEl.scrollWidth;this.contentWrapperEl.style.height=i?"auto":"100%",this.placeholderEl.style.width=s?"".concat(t||a,"px"):"auto",this.placeholderEl.style.height="".concat(n,"px");var c=this.contentWrapperEl.offsetHeight;this.axis.x.isOverflowing=0!==t&&a>t,this.axis.y.isOverflowing=n>c,this.axis.x.isOverflowing="hidden"!==l&&this.axis.x.isOverflowing,this.axis.y.isOverflowing="hidden"!==o&&this.axis.y.isOverflowing,this.axis.x.forceVisible="x"===this.options.forceVisible||!0===this.options.forceVisible,this.axis.y.forceVisible="y"===this.options.forceVisible||!0===this.options.forceVisible,this.hideNativeScrollbar();var h=this.axis.x.isOverflowing?this.scrollbarWidth:0,d=this.axis.y.isOverflowing?this.scrollbarWidth:0;this.axis.x.isOverflowing=this.axis.x.isOverflowing&&a>r-d,this.axis.y.isOverflowing=this.axis.y.isOverflowing&&n>c-h,this.axis.x.scrollbar.size=this.getScrollbarSize("x"),this.axis.y.scrollbar.size=this.getScrollbarSize("y"),this.axis.x.scrollbar.el.style.width="".concat(this.axis.x.scrollbar.size,"px"),this.axis.y.scrollbar.el.style.height="".concat(this.axis.y.scrollbar.size,"px"),this.positionScrollbar("x"),this.positionScrollbar("y"),this.toggleTrackVisibility("x"),this.toggleTrackVisibility("y")}},{key:"getScrollbarSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";if(!this.axis[e].isOverflowing)return 0;var t,i=this.contentEl[this.axis[e].scrollSizeAttr],s=this.axis[e].track.el[this.axis[e].offsetSizeAttr],r=s/i;return t=Math.max(~~(r*s),this.options.scrollbarMinSize),this.options.scrollbarMaxSize&&(t=Math.min(t,this.options.scrollbarMaxSize)),t}},{key:"positionScrollbar",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";if(this.axis[e].isOverflowing){var i=this.contentWrapperEl[this.axis[e].scrollSizeAttr],s=this.axis[e].track.el[this.axis[e].offsetSizeAttr],r=parseInt(this.elStyles[this.axis[e].sizeAttr],10),l=this.axis[e].scrollbar,o=this.contentWrapperEl[this.axis[e].scrollOffsetAttr],n=(o="x"===e&&this.isRtl&&t.getRtlHelpers().isScrollOriginAtZero?-o:o)/(i-r),a=~~((s-l.size)*n);a="x"===e&&this.isRtl&&t.getRtlHelpers().isScrollingToNegative?-a+(s-l.size):a,l.el.style.transform="x"===e?"translate3d(".concat(a,"px, 0, 0)"):"translate3d(0, ".concat(a,"px, 0)")}}},{key:"toggleTrackVisibility",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y",t=this.axis[e].track.el,i=this.axis[e].scrollbar.el;this.axis[e].isOverflowing||this.axis[e].forceVisible?(t.style.visibility="visible",this.contentWrapperEl.style[this.axis[e].overflowAttr]="scroll",this.el.classList.add("".concat(this.classNames.scrollable,"-").concat(e))):(t.style.visibility="hidden",this.contentWrapperEl.style[this.axis[e].overflowAttr]="hidden",this.el.classList.remove("".concat(this.classNames.scrollable,"-").concat(e))),this.axis[e].isOverflowing?i.style.display="block":i.style.display="none"}},{key:"hideNativeScrollbar",value:function(){this.offsetEl.style[this.isRtl?"left":"right"]=this.axis.y.isOverflowing||this.axis.y.forceVisible?"-".concat(this.scrollbarWidth,"px"):0,this.offsetEl.style.bottom=this.axis.x.isOverflowing||this.axis.x.forceVisible?"-".concat(this.scrollbarWidth,"px"):0}},{key:"onMouseMoveForAxis",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";this.axis[e].track.rect=this.axis[e].track.el.getBoundingClientRect(),this.axis[e].scrollbar.rect=this.axis[e].scrollbar.el.getBoundingClientRect();var t=this.isWithinBounds(this.axis[e].scrollbar.rect);t?this.axis[e].scrollbar.el.classList.add(this.classNames.hover):this.axis[e].scrollbar.el.classList.remove(this.classNames.hover),this.isWithinBounds(this.axis[e].track.rect)?this.axis[e].track.el.classList.add(this.classNames.hover):this.axis[e].track.el.classList.remove(this.classNames.hover)}},{key:"onMouseLeaveForAxis",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";this.axis[e].track.el.classList.remove(this.classNames.hover),this.axis[e].scrollbar.el.classList.remove(this.classNames.hover)}},{key:"onDragStart",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",i=C(this.el),s=N(this.el),r=this.axis[t].scrollbar,l="y"===t?e.pageY:e.pageX;this.axis[t].dragOffset=l-r.rect[this.axis[t].offsetAttr],this.draggedAxis=t,this.el.classList.add(this.classNames.dragging),i.addEventListener("mousemove",this.drag,!0),i.addEventListener("mouseup",this.onEndDrag,!0),null===this.removePreventClickId?(i.addEventListener("click",this.preventClick,!0),i.addEventListener("dblclick",this.preventClick,!0)):(s.clearTimeout(this.removePreventClickId),this.removePreventClickId=null)}},{key:"onTrackClick",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";if(this.options.clickOnTrack){e.preventDefault();var s=N(this.el);this.axis[i].scrollbar.rect=this.axis[i].scrollbar.el.getBoundingClientRect();var r=this.axis[i].scrollbar,l=r.rect[this.axis[i].offsetAttr],o=parseInt(this.elStyles[this.axis[i].sizeAttr],10),n=this.contentWrapperEl[this.axis[i].scrollOffsetAttr],a="y"===i?this.mouseY-l:this.mouseX-l,c=a<0?-1:1,h=-1===c?n-o:n+o,d=40,u=function e(){-1===c?n>h&&(n-=d,t.contentWrapperEl[t.axis[i].scrollOffsetAttr]=n,s.requestAnimationFrame(e)):n<h&&(n+=d,t.contentWrapperEl[t.axis[i].scrollOffsetAttr]=n,s.requestAnimationFrame(e))};u()}}},{key:"getContentElement",value:function(){return this.contentEl}},{key:"getScrollElement",value:function(){return this.contentWrapperEl}},{key:"removeListeners",value:function(){var e=N(this.el);this.el.removeEventListener("mouseenter",this.onMouseEnter),this.el.removeEventListener("pointerdown",this.onPointerEvent,!0),this.el.removeEventListener("mousemove",this.onMouseMove),this.el.removeEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl&&this.contentWrapperEl.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onWindowResize),this.mutationObserver&&this.mutationObserver.disconnect(),this.resizeObserver&&this.resizeObserver.disconnect(),this.onMouseMove.cancel(),this.onWindowResize.cancel(),this.onStopScrolling.cancel(),this.onMouseEntered.cancel()}},{key:"unMount",value:function(){this.removeListeners(),t.instances.delete(this.el)}},{key:"isWithinBounds",value:function(e){return this.mouseX>=e.left&&this.mouseX<=e.left+e.width&&this.mouseY>=e.top&&this.mouseY<=e.top+e.height}},{key:"findChild",value:function(e,t){var i=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector;return Array.prototype.filter.call(e.children,(function(e){return i.call(e,t)}))[0]}}])&&s(r.prototype,l),o&&s(r,o),t}();D.defaultOptions={autoHide:!0,forceVisible:!1,clickOnTrack:!0,scrollbarMinSize:25,scrollbarMaxSize:0},D.instances=new WeakMap;var R=function(e){return Array.prototype.reduce.call(e,(function(e,t){var i=t.name.match(/data-simplebar-(.+)/);if(i){var s=i[1].replace(/\W+(.)/g,(function(e,t){return t.toUpperCase()}));switch(t.value){case"true":e[s]=!0;break;case"false":e[s]=!1;break;case void 0:e[s]=!0;break;default:e[s]=t.value}}return e}),{})};return D.initDOMLoadedElements=function(){document.removeEventListener("DOMContentLoaded",this.initDOMLoadedElements),window.removeEventListener("load",this.initDOMLoadedElements),Array.prototype.forEach.call(document.querySelectorAll("[data-simplebar]"),(function(e){"init"===e.getAttribute("data-simplebar")||D.instances.has(e)||new D(e,R(e.attributes))}))},D.removeObserver=function(){this.globalObserver.disconnect()},D.initHtmlApi=function(){this.initDOMLoadedElements=this.initDOMLoadedElements.bind(this),"undefined"!=typeof MutationObserver&&(this.globalObserver=new MutationObserver(D.handleMutations),this.globalObserver.observe(document,{childList:!0,subtree:!0})),"complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?window.setTimeout(this.initDOMLoadedElements):(document.addEventListener("DOMContentLoaded",this.initDOMLoadedElements),window.addEventListener("load",this.initDOMLoadedElements))},D.handleMutations=function(e){e.forEach((function(e){Array.prototype.forEach.call(e.addedNodes,(function(e){1===e.nodeType&&(e.hasAttribute("data-simplebar")?!D.instances.has(e)&&new D(e,R(e.attributes)):Array.prototype.forEach.call(e.querySelectorAll("[data-simplebar]"),(function(e){"init"===e.getAttribute("data-simplebar")||D.instances.has(e)||new D(e,R(e.attributes))})))})),Array.prototype.forEach.call(e.removedNodes,(function(e){1===e.nodeType&&(e.hasAttribute("data-simplebar")?D.instances.has(e)&&D.instances.get(e).unMount():Array.prototype.forEach.call(e.querySelectorAll('[data-simplebar="init"]'),(function(e){D.instances.has(e)&&D.instances.get(e).unMount()})))}))}))},D.getOptions=R,D.default=D,e&&D.initHtmlApi(),D})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).SimpleBar=t()}(this,(function(){"use strict";var e=!("undefined"==typeof window||!window.document||!window.document.createElement);function t(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}var r="object"==typeof global&&global&&global.Object===Object&&global,l="object"==typeof self&&self&&self.Object===Object&&self,o=r||l||Function("return this")(),n=o.Symbol,a=Object.prototype,c=a.hasOwnProperty,h=a.toString,d=n?n.toStringTag:void 0;var u=Object.prototype.toString;var f=n?n.toStringTag:void 0;function p(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":f&&f in Object(e)?function(e){var t=c.call(e,d),i=e[d];try{e[d]=void 0;var s=!0}catch(e){}var r=h.call(e);return s&&(t?e[d]=i:delete e[d]),r}(e):function(e){return u.call(e)}(e)}function v(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var m=/^\s+|\s+$/g,g=/^[-+]0x[0-9a-f]+$/i,b=/^0b[01]+$/i,y=/^0o[0-7]+$/i,x=parseInt;function E(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==p(e)}(e))return NaN;if(v(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=v(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(m,"");var i=b.test(e);return i||y.test(e)?x(e.slice(2),i?2:8):g.test(e)?NaN:+e}var O=function(){return o.Date.now()},w=Math.max,S=Math.min;function k(e,t,i){var s,r,l,o,n,a,c=0,h=!1,d=!1,u=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var i=s,l=r;return s=r=void 0,c=t,o=e.apply(l,i)}function p(e){return c=e,n=setTimeout(g,t),h?f(e):o}function m(e){var i=e-a;return void 0===a||i>=t||i<0||d&&e-c>=l}function g(){var e=O();if(m(e))return b(e);n=setTimeout(g,function(e){var i=t-(e-a);return d?S(i,l-(e-c)):i}(e))}function b(e){return n=void 0,u&&s?f(e):(s=r=void 0,o)}function y(){var e=O(),i=m(e);if(s=arguments,r=this,a=e,i){if(void 0===n)return p(a);if(d)return clearTimeout(n),n=setTimeout(g,t),f(a)}return void 0===n&&(n=setTimeout(g,t)),o}return t=E(t)||0,v(i)&&(h=!!i.leading,l=(d="maxWait"in i)?w(E(i.maxWait)||0,t):l,u="trailing"in i?!!i.trailing:u),y.cancel=function(){void 0!==n&&clearTimeout(n),c=0,s=a=r=n=void 0},y.flush=function(){return void 0===n?o:b(O())},y}function A(e,t,i){var s=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return v(i)&&(s="leading"in i?!!i.leading:s,r="trailing"in i?!!i.trailing:r),k(e,t,{leading:s,maxWait:t,trailing:r})}var L=null,M=null;function W(){if(null===L){if("undefined"==typeof document)return L=0;var e=document.body,t=document.createElement("div");t.classList.add("simplebar-hide-scrollbar"),e.appendChild(t);var i=t.getBoundingClientRect().right;e.removeChild(t),L=i}return L}function N(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window}function C(e){return e&&e.ownerDocument?e.ownerDocument:document}function z(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function T(e){for(var i=1;i<arguments.length;i++){var s=null!=arguments[i]?arguments[i]:{};i%2?z(Object(s),!0).forEach((function(i){t(e,i,s[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):z(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}e&&window.addEventListener("resize",(function(){M!==window.devicePixelRatio&&(M=window.devicePixelRatio,L=null)}));var D=function(){function t(e){var s=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,t),this.onScroll=function(){var e=N(s.el);s.scrollXTicking||(e.requestAnimationFrame(s.scrollX),s.scrollXTicking=!0),s.scrollYTicking||(e.requestAnimationFrame(s.scrollY),s.scrollYTicking=!0),s.isScrolling||(s.isScrolling=!0,s.el.classList.add(s.classNames.scrolling)),s.onStopScrolling()},this.scrollX=function(){s.axis.x.isOverflowing&&s.positionScrollbar("x"),s.scrollXTicking=!1},this.scrollY=function(){s.axis.y.isOverflowing&&s.positionScrollbar("y"),s.scrollYTicking=!1},this.onStopScrolling=function(){s.el.classList.remove(s.classNames.scrolling),s.isScrolling=!1},this.onMouseEnter=function(){s.isMouseEntering||(s.el.classList.add(s.classNames.mouseEntered),s.isMouseEntering=!0),s.onMouseEntered()},this.onMouseEntered=function(){s.el.classList.remove(s.classNames.mouseEntered),s.isMouseEntering=!1},this.onMouseMove=function(e){s.mouseX=e.clientX,s.mouseY=e.clientY,(s.axis.x.isOverflowing||s.axis.x.forceVisible)&&s.onMouseMoveForAxis("x"),(s.axis.y.isOverflowing||s.axis.y.forceVisible)&&s.onMouseMoveForAxis("y")},this.onMouseLeave=function(){s.onMouseMove.cancel(),(s.axis.x.isOverflowing||s.axis.x.forceVisible)&&s.onMouseLeaveForAxis("x"),(s.axis.y.isOverflowing||s.axis.y.forceVisible)&&s.onMouseLeaveForAxis("y"),s.mouseX=-1,s.mouseY=-1},this.onWindowResize=function(){s.scrollbarWidth=t.getScrollbarWidth(),s.hideNativeScrollbar()},this.onPointerEvent=function(e){var t,i;s.axis.x.track.rect=s.axis.x.track.el.getBoundingClientRect(),s.axis.y.track.rect=s.axis.y.track.el.getBoundingClientRect(),(s.axis.x.isOverflowing||s.axis.x.forceVisible)&&(t=s.isWithinBounds(s.axis.x.track.rect)),(s.axis.y.isOverflowing||s.axis.y.forceVisible)&&(i=s.isWithinBounds(s.axis.y.track.rect)),(t||i)&&(e.stopPropagation(),"pointerdown"===e.type&&"touch"!==e.pointerType&&(t&&(s.axis.x.scrollbar.rect=s.axis.x.scrollbar.el.getBoundingClientRect(),s.isWithinBounds(s.axis.x.scrollbar.rect)?s.onDragStart(e,"x"):s.onTrackClick(e,"x")),i&&(s.axis.y.scrollbar.rect=s.axis.y.scrollbar.el.getBoundingClientRect(),s.isWithinBounds(s.axis.y.scrollbar.rect)?s.onDragStart(e,"y"):s.onTrackClick(e,"y"))))},this.drag=function(e){var i=s.axis[s.draggedAxis].track,r=i.rect[s.axis[s.draggedAxis].sizeAttr],l=s.axis[s.draggedAxis].scrollbar,o=s.contentWrapperEl[s.axis[s.draggedAxis].scrollSizeAttr],n=parseInt(s.elStyles[s.axis[s.draggedAxis].sizeAttr],10);e.preventDefault(),e.stopPropagation();var a=(("y"===s.draggedAxis?e.pageY:e.pageX)-i.rect[s.axis[s.draggedAxis].offsetAttr]-s.axis[s.draggedAxis].dragOffset)/(r-l.size)*(o-n);"x"===s.draggedAxis&&(a=s.isRtl&&t.getRtlHelpers().isScrollOriginAtZero?a-(r+l.size):a),s.contentWrapperEl[s.axis[s.draggedAxis].scrollOffsetAttr]=a},this.onEndDrag=function(e){var t=C(s.el),i=N(s.el);e.preventDefault(),e.stopPropagation(),s.el.classList.remove(s.classNames.dragging),t.removeEventListener("mousemove",s.drag,!0),t.removeEventListener("mouseup",s.onEndDrag,!0),s.removePreventClickId=i.setTimeout((function(){t.removeEventListener("click",s.preventClick,!0),t.removeEventListener("dblclick",s.preventClick,!0),s.removePreventClickId=null}))},this.preventClick=function(e){e.preventDefault(),e.stopPropagation()},this.el=e,this.minScrollbarWidth=20,this.stopScrollDelay=175,this.options=T(T({},t.defaultOptions),r),this.classNames=T({contentEl:"simplebar-content",contentWrapper:"simplebar-content-wrapper",offset:"simplebar-offset",mask:"simplebar-mask",wrapper:"simplebar-wrapper",placeholder:"simplebar-placeholder",scrollbar:"simplebar-scrollbar",track:"simplebar-track",heightAutoObserverWrapperEl:"simplebar-height-auto-observer-wrapper",heightAutoObserverEl:"simplebar-height-auto-observer",visible:"simplebar-visible",horizontal:"simplebar-horizontal",vertical:"simplebar-vertical",hover:"simplebar-hover",dragging:"simplebar-dragging",scrolling:"simplebar-scrolling",scrollable:"simplebar-scrollable",mouseEntered:"simplebar-mouse-entered"},this.options.classNames),this.axis={x:{scrollOffsetAttr:"scrollLeft",sizeAttr:"width",scrollSizeAttr:"scrollWidth",offsetSizeAttr:"offsetWidth",offsetAttr:"left",overflowAttr:"overflowX",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}},y:{scrollOffsetAttr:"scrollTop",sizeAttr:"height",scrollSizeAttr:"scrollHeight",offsetSizeAttr:"offsetHeight",offsetAttr:"top",overflowAttr:"overflowY",dragOffset:0,isOverflowing:!0,isVisible:!1,forceVisible:!1,track:{},scrollbar:{}}},this.removePreventClickId=null,this.isScrolling=!1,this.isMouseEntering=!1,t.instances.has(this.el)||(r.classNames&&console.warn("simplebar: classNames option is deprecated. Please override the styles with CSS instead."),r.autoHide&&console.warn("simplebar: autoHide option is deprecated. Please use CSS instead: '.simplebar-scrollbar::before { opacity: 0.5 };' for autoHide: false"),this.onMouseMove=A(this.onMouseMove,64),this.onWindowResize=k(this.onWindowResize,64,{leading:!0}),this.onStopScrolling=k(this.onStopScrolling,this.stopScrollDelay),this.onMouseEntered=k(this.onMouseEntered,this.stopScrollDelay),this.init())}var r,l,o;return r=t,o=[{key:"getRtlHelpers",value:function(){if(t.rtlHelpers)return t.rtlHelpers;var e=document.createElement("div");e.innerHTML='<div class="simplebar-dummy-scrollbar-size"><div></div></div>';var i=e.firstElementChild,s=i.firstElementChild;document.body.appendChild(i),i.scrollLeft=0;var r=t.getOffset(i),l=t.getOffset(s);i.scrollLeft=-999;var o=t.getOffset(s);return document.body.removeChild(i),t.rtlHelpers={isScrollOriginAtZero:r.left!==l.left,isScrollingToNegative:l.left!==o.left},t.rtlHelpers}},{key:"getScrollbarWidth",value:function(){try{return"none"===getComputedStyle(this.contentWrapperEl,"::-webkit-scrollbar").display||"scrollbarWidth"in document.documentElement.style||"-ms-overflow-style"in document.documentElement.style?0:W()}catch(e){return W()}}},{key:"getOffset",value:function(e){var t=e.getBoundingClientRect(),i=C(e),s=N(e);return{top:t.top+(s.pageYOffset||i.documentElement.scrollTop),left:t.left+(s.pageXOffset||i.documentElement.scrollLeft)}}}],(l=[{key:"init",value:function(){t.instances.set(this.el,this),e&&(this.initDOM(),this.rtlHelpers=t.getRtlHelpers(),this.scrollbarWidth=t.getScrollbarWidth(),this.recalculate(),this.initListeners())}},{key:"initDOM",value:function(){var e=this;if(Array.prototype.filter.call(this.el.children,(function(t){return t.classList.contains(e.classNames.wrapper)})).length)this.wrapperEl=this.el.querySelector(".".concat(this.classNames.wrapper)),this.contentWrapperEl=this.options.scrollableNode||this.el.querySelector(".".concat(this.classNames.contentWrapper)),this.contentEl=this.options.contentNode||this.el.querySelector(".".concat(this.classNames.contentEl)),this.offsetEl=this.el.querySelector(".".concat(this.classNames.offset)),this.maskEl=this.el.querySelector(".".concat(this.classNames.mask)),this.placeholderEl=this.findChild(this.wrapperEl,".".concat(this.classNames.placeholder)),this.heightAutoObserverWrapperEl=this.el.querySelector(".".concat(this.classNames.heightAutoObserverWrapperEl)),this.heightAutoObserverEl=this.el.querySelector(".".concat(this.classNames.heightAutoObserverEl)),this.axis.x.track.el=this.findChild(this.el,".".concat(this.classNames.track,".").concat(this.classNames.horizontal)),this.axis.y.track.el=this.findChild(this.el,".".concat(this.classNames.track,".").concat(this.classNames.vertical));else{for(this.wrapperEl=document.createElement("div"),this.contentWrapperEl=document.createElement("div"),this.offsetEl=document.createElement("div"),this.maskEl=document.createElement("div"),this.contentEl=document.createElement("div"),this.placeholderEl=document.createElement("div"),this.heightAutoObserverWrapperEl=document.createElement("div"),this.heightAutoObserverEl=document.createElement("div"),this.wrapperEl.classList.add(this.classNames.wrapper),this.contentWrapperEl.classList.add(this.classNames.contentWrapper),this.offsetEl.classList.add(this.classNames.offset),this.maskEl.classList.add(this.classNames.mask),this.contentEl.classList.add(this.classNames.contentEl),this.placeholderEl.classList.add(this.classNames.placeholder),this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl),this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);this.el.firstChild;)this.contentEl.appendChild(this.el.firstChild);this.contentWrapperEl.appendChild(this.contentEl),this.offsetEl.appendChild(this.contentWrapperEl),this.maskEl.appendChild(this.offsetEl),this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl),this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl),this.wrapperEl.appendChild(this.maskEl),this.wrapperEl.appendChild(this.placeholderEl),this.el.appendChild(this.wrapperEl)}if(!this.axis.x.track.el||!this.axis.y.track.el){var t=document.createElement("div"),i=document.createElement("div");t.classList.add(this.classNames.track),i.classList.add(this.classNames.scrollbar),t.appendChild(i),this.axis.x.track.el=t.cloneNode(!0),this.axis.x.track.el.classList.add(this.classNames.horizontal),this.axis.y.track.el=t.cloneNode(!0),this.axis.y.track.el.classList.add(this.classNames.vertical),this.el.appendChild(this.axis.x.track.el),this.el.appendChild(this.axis.y.track.el)}this.axis.x.scrollbar.el=this.axis.x.track.el.querySelector(".".concat(this.classNames.scrollbar)),this.axis.y.scrollbar.el=this.axis.y.track.el.querySelector(".".concat(this.classNames.scrollbar)),this.options.autoHide||(this.axis.x.scrollbar.el.classList.add(this.classNames.visible),this.axis.y.scrollbar.el.classList.add(this.classNames.visible)),this.el.setAttribute("data-simplebar","init")}},{key:"initListeners",value:function(){var e=this,t=N(this.el);if(this.el.addEventListener("mouseenter",this.onMouseEnter),this.el.addEventListener("pointerdown",this.onPointerEvent,!0),this.el.addEventListener("mousemove",this.onMouseMove),this.el.addEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl.addEventListener("scroll",this.onScroll),t.addEventListener("resize",this.onWindowResize),window.ResizeObserver){var i=!1,s=t.ResizeObserver||ResizeObserver;this.resizeObserver=new s((function(){i&&t.requestAnimationFrame((function(){e.recalculate()}))})),this.resizeObserver.observe(this.el),this.resizeObserver.observe(this.contentEl),t.requestAnimationFrame((function(){i=!0}))}this.mutationObserver=new t.MutationObserver((function(){t.requestAnimationFrame((function(){e.recalculate()}))})),this.mutationObserver.observe(this.contentEl,{childList:!0,subtree:!0,characterData:!0})}},{key:"recalculate",value:function(){var e=N(this.el);this.elStyles=e.getComputedStyle(this.el),this.isRtl="rtl"===this.elStyles.direction;var t=this.contentEl.offsetWidth,i=this.heightAutoObserverEl.offsetHeight<=1,s=this.heightAutoObserverEl.offsetWidth<=1||t>0,r=this.contentWrapperEl.offsetWidth,l=this.elStyles.overflowX,o=this.elStyles.overflowY;this.contentEl.style.padding="".concat(this.elStyles.paddingTop," ").concat(this.elStyles.paddingRight," ").concat(this.elStyles.paddingBottom," ").concat(this.elStyles.paddingLeft),this.wrapperEl.style.margin="-".concat(this.elStyles.paddingTop," -").concat(this.elStyles.paddingRight," -").concat(this.elStyles.paddingBottom," -").concat(this.elStyles.paddingLeft);var n=this.contentEl.scrollHeight,a=this.contentEl.scrollWidth;this.contentWrapperEl.style.height=i?"auto":"100%",this.placeholderEl.style.width=s?"".concat(t||a,"px"):"auto",this.placeholderEl.style.height="".concat(n,"px");var c=this.contentWrapperEl.offsetHeight;this.axis.x.isOverflowing=0!==t&&a>t,this.axis.y.isOverflowing=n>c,this.axis.x.isOverflowing="hidden"!==l&&this.axis.x.isOverflowing,this.axis.y.isOverflowing="hidden"!==o&&this.axis.y.isOverflowing,this.axis.x.forceVisible="x"===this.options.forceVisible||!0===this.options.forceVisible,this.axis.y.forceVisible="y"===this.options.forceVisible||!0===this.options.forceVisible,this.hideNativeScrollbar();var h=this.axis.x.isOverflowing?this.scrollbarWidth:0,d=this.axis.y.isOverflowing?this.scrollbarWidth:0;this.axis.x.isOverflowing=this.axis.x.isOverflowing&&a>r-d,this.axis.y.isOverflowing=this.axis.y.isOverflowing&&n>c-h,this.axis.x.scrollbar.size=this.getScrollbarSize("x"),this.axis.y.scrollbar.size=this.getScrollbarSize("y"),this.axis.x.scrollbar.el.style.width="".concat(this.axis.x.scrollbar.size,"px"),this.axis.y.scrollbar.el.style.height="".concat(this.axis.y.scrollbar.size,"px"),this.positionScrollbar("x"),this.positionScrollbar("y"),this.toggleTrackVisibility("x"),this.toggleTrackVisibility("y")}},{key:"getScrollbarSize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";if(!this.axis[e].isOverflowing)return 0;var t,i=this.contentEl[this.axis[e].scrollSizeAttr],s=this.axis[e].track.el[this.axis[e].offsetSizeAttr],r=s/i;return t=Math.max(~~(r*s),this.options.scrollbarMinSize),this.options.scrollbarMaxSize&&(t=Math.min(t,this.options.scrollbarMaxSize)),t}},{key:"positionScrollbar",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";if(this.axis[e].isOverflowing){var i=this.contentWrapperEl[this.axis[e].scrollSizeAttr],s=this.axis[e].track.el[this.axis[e].offsetSizeAttr],r=parseInt(this.elStyles[this.axis[e].sizeAttr],10),l=this.axis[e].scrollbar,o=this.contentWrapperEl[this.axis[e].scrollOffsetAttr],n=(o="x"===e&&this.isRtl&&t.getRtlHelpers().isScrollOriginAtZero?-o:o)/(i-r),a=~~((s-l.size)*n);a="x"===e&&this.isRtl&&t.getRtlHelpers().isScrollingToNegative?-a+(s-l.size):a,l.el.style.transform="x"===e?"translate3d(".concat(a,"px, 0, 0)"):"translate3d(0, ".concat(a,"px, 0)")}}},{key:"toggleTrackVisibility",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y",t=this.axis[e].track.el,i=this.axis[e].scrollbar.el;this.axis[e].isOverflowing||this.axis[e].forceVisible?(t.style.visibility="visible",this.contentWrapperEl.style[this.axis[e].overflowAttr]="scroll",this.el.classList.add("".concat(this.classNames.scrollable,"-").concat(e))):(t.style.visibility="hidden",this.contentWrapperEl.style[this.axis[e].overflowAttr]="hidden",this.el.classList.remove("".concat(this.classNames.scrollable,"-").concat(e))),this.axis[e].isOverflowing?i.style.display="block":i.style.display="none"}},{key:"hideNativeScrollbar",value:function(){this.offsetEl.style[this.isRtl?"left":"right"]=this.axis.y.isOverflowing||this.axis.y.forceVisible?"-".concat(this.scrollbarWidth,"px"):0,this.offsetEl.style.bottom=this.axis.x.isOverflowing||this.axis.x.forceVisible?"-".concat(this.scrollbarWidth,"px"):0}},{key:"onMouseMoveForAxis",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";this.axis[e].track.rect=this.axis[e].track.el.getBoundingClientRect(),this.axis[e].scrollbar.rect=this.axis[e].scrollbar.el.getBoundingClientRect();var t=this.isWithinBounds(this.axis[e].scrollbar.rect);t?this.axis[e].scrollbar.el.classList.add(this.classNames.hover):this.axis[e].scrollbar.el.classList.remove(this.classNames.hover),this.isWithinBounds(this.axis[e].track.rect)?this.axis[e].track.el.classList.add(this.classNames.hover):this.axis[e].track.el.classList.remove(this.classNames.hover)}},{key:"onMouseLeaveForAxis",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"y";this.axis[e].track.el.classList.remove(this.classNames.hover),this.axis[e].scrollbar.el.classList.remove(this.classNames.hover)}},{key:"onDragStart",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",i=C(this.el),s=N(this.el),r=this.axis[t].scrollbar,l="y"===t?e.pageY:e.pageX;this.axis[t].dragOffset=l-r.rect[this.axis[t].offsetAttr],this.draggedAxis=t,this.el.classList.add(this.classNames.dragging),i.addEventListener("mousemove",this.drag,!0),i.addEventListener("mouseup",this.onEndDrag,!0),null===this.removePreventClickId?(i.addEventListener("click",this.preventClick,!0),i.addEventListener("dblclick",this.preventClick,!0)):(s.clearTimeout(this.removePreventClickId),this.removePreventClickId=null)}},{key:"onTrackClick",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";if(this.options.clickOnTrack){e.preventDefault();var s=N(this.el);this.axis[i].scrollbar.rect=this.axis[i].scrollbar.el.getBoundingClientRect();var r=this.axis[i].scrollbar,l=r.rect[this.axis[i].offsetAttr],o=parseInt(this.elStyles[this.axis[i].sizeAttr],10),n=this.contentWrapperEl[this.axis[i].scrollOffsetAttr],a="y"===i?this.mouseY-l:this.mouseX-l,c=a<0?-1:1,h=-1===c?n-o:n+o,d=40,u=function e(){-1===c?n>h&&(n-=d,t.contentWrapperEl[t.axis[i].scrollOffsetAttr]=n,s.requestAnimationFrame(e)):n<h&&(n+=d,t.contentWrapperEl[t.axis[i].scrollOffsetAttr]=n,s.requestAnimationFrame(e))};u()}}},{key:"getContentElement",value:function(){return this.contentEl}},{key:"getScrollElement",value:function(){return this.contentWrapperEl}},{key:"removeListeners",value:function(){var e=N(this.el);this.el.removeEventListener("mouseenter",this.onMouseEnter),this.el.removeEventListener("pointerdown",this.onPointerEvent,!0),this.el.removeEventListener("mousemove",this.onMouseMove),this.el.removeEventListener("mouseleave",this.onMouseLeave),this.contentWrapperEl&&this.contentWrapperEl.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onWindowResize),this.mutationObserver&&this.mutationObserver.disconnect(),this.resizeObserver&&this.resizeObserver.disconnect(),this.onMouseMove.cancel(),this.onWindowResize.cancel(),this.onStopScrolling.cancel(),this.onMouseEntered.cancel()}},{key:"unMount",value:function(){this.removeListeners(),t.instances.delete(this.el)}},{key:"isWithinBounds",value:function(e){return this.mouseX>=e.left&&this.mouseX<=e.left+e.width&&this.mouseY>=e.top&&this.mouseY<=e.top+e.height}},{key:"findChild",value:function(e,t){var i=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector;return Array.prototype.filter.call(e.children,(function(e){return i.call(e,t)}))[0]}}])&&s(r.prototype,l),o&&s(r,o),t}();D.defaultOptions={autoHide:!0,forceVisible:!1,clickOnTrack:!0,scrollbarMinSize:25,scrollbarMaxSize:0},D.instances=new WeakMap;var R=function(e){return Array.prototype.reduce.call(e,(function(e,t){var i=t.name.match(/data-simplebar-(.+)/);if(i){var s=i[1].replace(/\W+(.)/g,(function(e,t){return t.toUpperCase()}));switch(t.value){case"true":e[s]=!0;break;case"false":e[s]=!1;break;case void 0:e[s]=!0;break;default:e[s]=t.value}}return e}),{})};return D.initDOMLoadedElements=function(){document.removeEventListener("DOMContentLoaded",this.initDOMLoadedElements),window.removeEventListener("load",this.initDOMLoadedElements),Array.prototype.forEach.call(document.querySelectorAll("[data-simplebar]"),(function(e){"init"===e.getAttribute("data-simplebar")||D.instances.has(e)||new D(e,R(e.attributes))}))},D.removeObserver=function(){this.globalObserver.disconnect()},D.initHtmlApi=function(){this.initDOMLoadedElements=this.initDOMLoadedElements.bind(this),"undefined"!=typeof MutationObserver&&(this.globalObserver=new MutationObserver(D.handleMutations),this.globalObserver.observe(document,{childList:!0,subtree:!0})),"complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?window.setTimeout(this.initDOMLoadedElements):(document.addEventListener("DOMContentLoaded",this.initDOMLoadedElements),window.addEventListener("load",this.initDOMLoadedElements))},D.handleMutations=function(e){e.forEach((function(e){Array.prototype.forEach.call(e.addedNodes,(function(e){1===e.nodeType&&(e.hasAttribute("data-simplebar")?!D.instances.has(e)&&new D(e,R(e.attributes)):Array.prototype.forEach.call(e.querySelectorAll("[data-simplebar]"),(function(e){"init"===e.getAttribute("data-simplebar")||D.instances.has(e)||new D(e,R(e.attributes))})))})),Array.prototype.forEach.call(e.removedNodes,(function(e){1===e.nodeType&&(e.hasAttribute("data-simplebar")?D.instances.has(e)&&D.instances.get(e).unMount():Array.prototype.forEach.call(e.querySelectorAll('[data-simplebar="init"]'),(function(e){D.instances.has(e)&&D.instances.get(e).unMount()})))}))}))},D.getOptions=R,D.default=D,e&&D.initHtmlApi(),D})); |
/** | ||
* simplebar - v6.0.0-beta.9 | ||
* simplebar - v6.0.0-beta.10 | ||
* Scrollbars, simpler. | ||
@@ -4,0 +4,0 @@ * https://grsmto.github.io/simplebar/ |
{ | ||
"version": "6.0.0-beta.9", | ||
"version": "6.0.0-beta.10", | ||
"name": "simplebar", | ||
@@ -34,3 +34,3 @@ "title": "SimpleBar.js", | ||
"can-use-dom": "^0.1.0", | ||
"simplebar-core": "^1.0.6" | ||
"simplebar-core": "^1.0.7" | ||
}, | ||
@@ -58,3 +58,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "11fe57835c12362ac8abc6014053868dee568f47" | ||
"gitHead": "2495b2259ca9e3602546a285c3433ee48e864d50" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
221071
16
2755
1
Updatedsimplebar-core@^1.0.7