mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-22 23:40:37 +03:00
1 line
6.1 KiB
JavaScript
1 line
6.1 KiB
JavaScript
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).OverlayScrollbars=r()}(this,(function(){"use strict";function e(e){return"number"==typeof e}function r(e){return"string"==typeof e}function t(e){return Array.isArray(e)}function n(r){var n=!!r&&r.length;return t(r)||!function(e){return"function"==typeof e}(r)&&e(n)&&n>-1&&n%1==0}function i(e,r){return function(e,r,t,n){if(void 0===n)return t?t[e]:r;t&&(t[e]=n)}("scrollLeft",0,e,r)}var o=/[^\x20\t\r\n\f]+/g,a=function(e,t){!function(e,t,n){var i,a=0,s=!1;if(e&&r(t)){var c=t.match(o)||[];for(s=c.length>0;i=c[a++];)s=n(e.classList,i)&&s}}(e,t,(function(e,r){return e.add(r)}))},s=function(e){return e?Object.keys(e):[]};function c(e,r){if(n(e))for(var t=0;t<e.length&&!1!==r(e[t],t,e);t++);else e&&c(s(e),(function(t){return r(e[t],t,e)}));return e}var u=function(e){if(Array.from)return Array.from(e);var r=[];return c(e,(function(e){r.push(e)})),r},l=function(e,r){!function(e,r,t){if(t){var i,o=r;e&&(n(t)?(i=document.createDocumentFragment(),c(t,(function(e){e===o&&(o=e.previousSibling),i.appendChild(e)}))):i=t,r&&(o?o!==r&&(o=o.nextSibling):o=e.firstChild),e.insertBefore(i,o))}}(e,null,r)},f=function e(r){if(n(r))c(u(r),(function(r){return e(r)}));else if(r){var t=r.parentNode;t&&t.removeChild(r)}},d=function(e){var r,t=document.createElement("div");return t.innerHTML=e.trim(),c((r=t)?u(r.childNodes):[],(function(e){return f(e)}))},v={w:0,h:0},h=function(){return{w:window.innerWidth,h:window.innerHeight}},w={animationiterationcount:1,columncount:1,fillopacity:1,flexgrow:1,flexshrink:1,fontweight:1,lineheight:1,opacity:1,order:1,orphans:1,widows:1,zindex:1,zoom:1},p=function(e,r,t){return null!=r?r.getPropertyValue(t):e.style[t]},y=function(r,t,n){try{r&&void 0!==r.style[t]&&(r.style[t]=function(r,t){return!w[r.toLowerCase()]&&e(t)?t+"px":t}(t,n))}catch(i){}};function b(e,n){var i=r(n);if(t(n)||i){var o=i?"":{};if(e){var a=window.getComputedStyle(e,null);o=i?p(e,a,n):n.reduce((function(r,t){return r[t]=p(e,a,t),r}),o)}return o}c(s(n),(function(r){return y(e,r,n[r])}))}var g={x:0,y:0},m=function(e){var r=e?function(e){return e.getBoundingClientRect()}(e):0;return r?{x:r.left+window.pageYOffset,y:r.top+window.pageXOffset}:g};var x=function(e,r){var t=r.get(e);if(!t)throw new TypeError("attempted to get private field on non-instance");return t.get?t.get.call(e):t.value};var S=function(e,r,t){var n=r.get(e);if(!n)throw new TypeError("attempted to set private field on non-instance");if(n.set)n.set.call(e,t);else{if(!n.writable)throw new TypeError("attempted to set read only private field");n.value=t}return t},z=["WebKit","Moz","O","MS","webkit","moz","o","ms"],O={},P=function(e){var r,t,n=O[e]||window[e];return r=O,t=e,Object.prototype.hasOwnProperty.call(r,t)||(c(z,(function(r){var t;return!(n=n||window[r+(t=e,t.charAt(0).toUpperCase()+t.slice(1))])})),O[e]=n),n};P("ResizeObserver");!function(e,r,t){e(t={path:r,exports:{},require:function(e,r){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==r&&t.path)}},t.exports),t.exports}((function(e){function r(){return e.exports=r=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},r.apply(this,arguments)}e.exports=r}));var E=["__TPL_","_TYPE__"],L=(["boolean","number","string","array","object","function","null"].reduce((function(e,r){return e[r]=E[0]+r+E[1],e}),{}),Math.abs),C=Math.round,j=function(e,r){l(e,r);var t,n=(t=r)?{w:t.clientWidth,h:t.clientHeight}:v,i=function(e){return e?{w:e.offsetWidth,h:e.offsetHeight}:v}(r);return{x:i.h-n.h,y:i.w-n.w}},k=function(){var e=window.screen.deviceXDPI||0,r=window.screen.logicalXDPI||1;return window.devicePixelRatio||e/r},A=new WeakMap,M=function(){function e(){A.set(this,{writable:!0,value:void 0}),S(this,A,new Set);var e,r,t=this,n=document.body,o=d('<div id="os-dummy-scrollbar-size"><div></div></div>')[0],s=o.firstChild,c=j(n,o),u={x:0===c.x,y:0===c.y};if(t.autoUpdateLoop=!1,t.nativeScrollbarSize=c,t.nativeScrollbarIsOverlaid=u,t.nativeScrollbarStyling=function(e){var r=!1;a(e,"os-viewport-native-scrollbars-invisible");try{r="none"===b(e,"scrollbar-width")||"none"===window.getComputedStyle(e,"::-webkit-scrollbar").getPropertyValue("display")}catch(t){}return r}(o),t.rtlScrollBehavior=function(e,r){b(e,{overflowX:"hidden",overflowY:"hidden"}),i(e,0);var t=m(e),n=m(r);i(e,-999);var o=m(r);return{i:t.x===n.x,n:n.x!==o.x}}(o,s),t.supportPassiveEvents=function(){var e=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){e=!0}}))}catch(r){}return e}(),t.supportResizeObserver=!!P("ResizeObserver"),r="style",null==(e=o)||e.removeAttribute(r),f(o),u.x&&u.y){var l=h(),v=k(),w=x(this,A);window.addEventListener("resize",(function(){if(w.size){var e=h(),r={w:e.w-l.w,h:e.h-l.h};if(0===r.w&&0===r.h)return;var i,a={w:L(r.w),h:L(r.h)},s={w:L(C(e.w/(l.w/100))),h:L(C(e.h/(l.h/100)))},c=k(),u=a.w>2&&a.h>2,d=(b=s.h,g=L(s.w),m=L(b),!(g!==m&&g+1!==m&&g-1!==m)),p=u&&d&&(c!==v&&v>0),y=t.nativeScrollbarSize;p&&(i=t.nativeScrollbarSize=j(n,o),f(o),y.x===i.x&&y.y===i.y||w.forEach((function(e){return e&&e(t)}))),l=e,v=c}var b,g,m}))}}var r=e.prototype;return r.addListener=function(e){x(this,A).add(e)},r.removeListener=function(e){x(this,A).delete(e)},e}();return function(){return[new M,d(' <div class="os-host"> <div class="os-resize-observer-host"></div> <div class="os-padding"> <div class="os-viewport"> <div class="os-content"> fdfhdfgh </div> </div> </div> <div class="os-scrollbar os-scrollbar-horizontal"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar os-scrollbar-vertical"> <div class="os-scrollbar-track"> <div class="os-scrollbar-handle"></div> </div> </div> <div class="os-scrollbar-corner"></div> </div>')]}})); |