Files
OverlayScrollbars/packages/overlayscrollbars/dist/overlayscrollbars.esm.min.js
T
2020-12-27 00:37:12 +01:00

1 line
12 KiB
JavaScript

const t=t=>null==t?""+t:Object.prototype.toString.call(t).replace(/^\[object (.+)\]$/,"$1").toLowerCase();function n(t){return"number"==typeof t}function e(t){return"string"==typeof t}function o(t){return"function"==typeof t}function r(t){return void 0===t}function i(t){return null===t}function s(t){return Array.isArray(t)}function c(t){return"object"==typeof t&&!s(t)&&!i(t)}function l(t){const e=!!t&&t.length;return s(t)||!o(t)&&n(e)&&e>-1&&e%1==0}function a(n){if(!n||!c(n)||"object"!==t(n))return!1;let e;const{hasOwnProperty:o}=Object.prototype,i=o.call(n,"constructor"),s=n.constructor&&n.constructor.prototype&&o.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!i&&!s)return!1;for(e in n);return r(e)||o.call(n,e)}function u(t,n,e,o){if(r(o))return e?e[t]:n;e&&(e[t]=o)}const d=(t,n)=>{null==t||t.removeAttribute(n)};function f(t,n){return u("scrollLeft",0,t,n)}function v(t,n){return u("scrollTop",0,t,n)}const h=/[^\x20\t\r\n\f]+/g,b=(t,n)=>{((t,n,o)=>{let r,i=0,s=!1;if(t&&e(n)){const e=n.match(h)||[];for(s=e.length>0;r=e[i++];)s=o(t.classList,r)&&s}})(t,n,(t,n)=>t.add(n))};function p(t,n){if(l(t))for(let e=0;e<t.length&&!1!==n(t[e],e,t);e++);else t&&p(Object.keys(t),e=>n(t[e],e,t));return t}const w=t=>{if(Array.from)return Array.from(t);const n=[];return p(t,t=>{n.push(t)}),n},_=t=>{t instanceof Set?t.forEach(t=>t&&t()):p(t,t=>t&&t())},g=(t,n)=>((t,n)=>{if(t){return(Element.prototype.matches||Element.prototype.msMatchesSelector).call(t,n)}return!1})(t,n),m=t=>t?w(t.childNodes):[],y=(t,n,e)=>{if(e){let o,r=n;t&&(l(e)?(o=document.createDocumentFragment(),p(e,t=>{t===r&&(r=t.previousSibling),o.appendChild(t)})):o=e,n&&(r?r!==n&&(r=r.nextSibling):r=t.firstChild),t.insertBefore(o,r))}},x=(t,n)=>{y(t,null,n)},z=(t,n)=>{y(t,t&&t.firstChild,n)},O=t=>{if(l(t))p(w(t),t=>O(t));else if(t){const e=(n=t)?n.parentElement:null;e&&e.removeChild(t)}var n},j=t=>{const n=document.createElement("div");return t&&function(t,n,e){if(r(e))return t?t.getAttribute(n):null;t&&t.setAttribute(n,e)}(n,"class",t),n},S=t=>{const n=j();return n.innerHTML=t.trim(),p(m(n),t=>O(t))},$={w:0,h:0},A=()=>({w:window.innerWidth,h:window.innerHeight}),k=t=>t?{w:t.offsetWidth,h:t.offsetHeight}:$;let C;const L=(t,n,e,o)=>{p(n.split(" "),n=>{t.removeEventListener(n,e,o)})},T=(t,n,e,o)=>{const r=(()=>{if(void 0===C){C=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){C=!0}}))}catch(t){}}return C})(),i=r&&o&&o.o||!1,s=o&&o.s||!1,c=o&&o.u||!1,l=[],a=r?{passive:i,capture:s}:s;return p(n.split(" "),n=>{const o=c?r=>{t.removeEventListener(n,o,s),e&&e(r)}:e;l.push(L.bind(null,t,n,o,s)),t.addEventListener(n,o,a)}),_.bind(0,l)},E=t=>t.stopPropagation(),P=t=>t.preventDefault(),q=(t,n,e)=>{if(t&&n){let o=!0;return p(e,e=>{t[e]!==n[e]&&(o=!1)}),o}return!1},F=(t,n)=>q(t,n,["w","h"]),I=(t,n)=>q(t,n,["t","r","b","l"]),M=(t,n)=>Object.prototype.hasOwnProperty.call(t,n),B=t=>t?Object.keys(t):[];function N(t,n,e,r,c,l,u){const d=[n,e,r,c,l,u];return"object"==typeof t&&!i(t)||o(t)||(t={}),p(d,n=>{p(B(n),e=>{const o=n[e];if(t===o)return!0;const r=s(o);if(o&&(a(o)||r)){const n=t[e];let i=n;r&&!s(n)?i=[]:r||a(n)||(i={}),t[e]=N(i,o)}else t[e]=o})}),t}const R={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},Y=(t,n)=>{const e=n?parseFloat(t):parseInt(t,10);return Number.isNaN(e)?0:e},D=(t,n,e)=>null!=n?n.getPropertyValue(e):t.style[e],G=(t,e,o)=>{try{t&&void 0!==t.style[e]&&(t.style[e]=((t,e)=>!R[t.toLowerCase()]&&n(e)?e+"px":e)(e,o))}catch(r){}};function J(t,n){const o=e(n);if(s(n)||o){let e=o?"":{};if(t){const r=window.getComputedStyle(t,null);e=o?D(t,r,n):n.reduce((n,e)=>(n[e]=D(t,r,e),n),e)}return e}p(B(n),e=>G(t,e,n[e]))}const K={x:0,y:0},U=t=>{const n=t?(t=>t.getBoundingClientRect())(t):0;return n?{x:n.left+window.pageYOffset,y:n.top+window.pageXOffset}:K};function V(t,n){const o={},r=B(t);p(r,e=>{o[e]={v:!1,p:n?t[e]:void 0}});return(i,c)=>{const l=(e(i)?[i]:i)||r;return p(l,e=>{const r=o[e],i=t[e],c=!n&&s(i),l=c?i[0]:i,a=c?i[1]:null;((t,n,e)=>{const r=o[t].p;o[t].p=n,o[t]._=r,o[t].v=e?!e(r,n):r!==n})(e,n?l:l(r.p,r._),a)}),((t,n)=>{const e=N({},o,{g:!1});return p(t,t=>{const r=n||o[t].v;e.g=e.g||r,e[t].v=r,o[t].v=!1}),e})(l,c)}}const W=t=>t.charAt(0).toUpperCase()+t.slice(1),X=["-webkit-","-moz-","-o-","-ms-"],H=["WebKit","Moz","O","MS","webkit","moz","o","ms"],Q={},Z={},tt=t=>{let n=Z[t];if(M(Z,t))return n;const e=W(t),o=j().style;return p(X,r=>{const i=r.replace(/-/g,""),s=[t,r+t,i+e,W(i)+e];return n=s.find(t=>void 0!==o[t]),!n}),Z[t]=n,n},nt=t=>{let n=Q[t]||window[t];return M(Q,t)||(p(H,e=>(n=n||window[e+W(t)],!n)),Q[t]=n),n};nt("ResizeObserver");var et=function(t,n,e){return t(e={path:n,exports:{},require:function(t,n){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==n&&e.path)}},e.exports),e.exports}((function(t){function n(){return t.exports=n=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},n.apply(this,arguments)}t.exports=n}));const{stringify:ot}=JSON,rt=["__TPL_","_TYPE__"],it=["boolean","number","string","array","object","function","null"].reduce((t,n)=>(t[n]=rt[0]+n+rt[1],t),{}),st=(n,o,i,c,l)=>{const u={},d=et({},n);return p(B(o).filter(t=>M(n,t)),f=>{const v=r(i[f])?{}:i[f],h=n[f],b=o[f],w=a(b),_=l?l+".":"";if(w&&a(h)){const t=st(h,b,v,c,_+f);u[f]=t.m,d[f]=t.O,p([d,u],t=>{(function(t){for(const n in t)return!1;return!0})(t[f])&&delete t[f]})}else if(!w){let n=!1;const o=[],r=[],i=t(h);if(p(s(b)?b:[b],t=>{let s;p(it,(n,e)=>{n===t&&(s=e)});const c=void 0===s;if(c&&e(h)){const e=t.split(" ");n=!!e.find(t=>t===h),o.push(...e)}else n=it[i]===t;return r.push(c?it.string:s),!n}),n){(s(h)||a(h)?ot(h)!==ot(v):h!==v)&&(u[f]=h)}else c&&console.warn(`The option "${_}${f}" wasn't set, because it doesn't accept the type [ ${i.toUpperCase()} ] with the value of "${h}".\r\nAccepted types are: [ ${r.join(", ").toUpperCase()} ].\r\n${o.length>0?`\r\nValid strings are: [ ${o.join(", ")} ].`:""}`);delete d[f]}}),{O:d,m:u}},ct=(t,n,e,o)=>st(t,n,e||{},o||!1);let lt;const{abs:at,round:ut}=Math,dt=(t,n)=>{x(t,n);const e=(o=n)?{w:o.clientWidth,h:o.clientHeight}:$;var o;const r=k(n);return{x:r.h-e.h,y:r.w-e.w}},ft=t=>{let n=!1;b(t,"os-viewport-scrollbar-styled");try{n="none"===J(t,"scrollbar-width")||"none"===window.getComputedStyle(t,"::-webkit-scrollbar").getPropertyValue("display")}catch(e){}return n},vt=(t,n)=>{J(t,{overflowX:"hidden",overflowY:"hidden",direction:"rtl"}),f(t,0);const e=U(t),o=U(n);f(t,-999);const r=U(n);return{i:e.x===o.x,n:o.x!==r.x}},ht=(t,n)=>{b(t,"flexbox-glue");const e=k(t),o=k(n),r=F(o,e);b(t,"flexbox-glue-max");const i=k(t),s=k(n),c=F(s,i);return r&&c},bt=()=>{const t=window.screen.deviceXDPI||0,n=window.screen.logicalXDPI||1;return window.devicePixelRatio||t/n},pt=()=>{const{body:t}=document,n=S('<div id="os-environment"><div></div></div>')[0],e=n.firstChild,o=new Set,r=dt(t,n),i={x:0===r.x,y:0===r.y},s={j:!1,S:r,$:i,A:ft(n),k:vt(n,e),C:ht(n,e),L(t){o.add(t)},T(t){o.delete(t)}};if(d(n,"style"),d(n,"class"),O(n),!i.x||!i.y){let e=A(),i=bt(),s=r;window.addEventListener("resize",()=>{if(o.size){const r=A(),c={w:r.w-e.w,h:r.h-e.h};if(0===c.w&&0===c.h)return;const l={w:at(c.w),h:at(c.h)},a={w:at(ut(r.w/(e.w/100))),h:at(ut(r.h/(e.h/100)))},u=bt(),d=l.w>2&&l.h>2,f=!((t,n)=>{const e=at(t),o=at(n);return!(e===o||e+1===o||e-1===o)})(a.w,a.h),v=u!==i&&i>0;if(d&&f&&v){const e=lt.S=dt(t,n);O(n),s.x===e.x&&s.y===e.y||_(o),s=e}e=r,i=u}})}return s},wt=()=>(lt||(lt=pt()),lt),_t=(t,n,e,o)=>{const{P:r,q:i}=function t(n){const e={P:{},q:{}};return p(B(n),o=>{const r=n[o];if(s(r))e.P[o]=r[1],e.q[o]=r[0];else{const n=t(r);e.P[o]=n.P,e.q[o]=n.q}}),e}(t),c=N({},i,ct(e||{},r,null,!0).m),l=V(n),a=V(c,!0),u=t=>{const n="boolean"==typeof t.F;const e=!0===t.F,r=l(e?null:t.I||(n?null:[]),e),i=a(e?null:t.M,!!t.M||e);(i.g||r.g)&&o(i,r)};return u({F:!0}),{q(t){if(t){const{m:n}=ct(t,r,c,!0);N(c,n),u({M:B(n)})}return c},B:t=>{u({F:!!t})},N:t=>{u({I:t})}}},gt=tt("margin-inline-end"),mt=tt("border-inline-end"),yt=(t,n)=>{const{host:e,viewport:o,content:r}=t,i=[],s=wt(),c=s.$,l=s.A,{q:a,B:u,N:d}=(s.C,gt&&mt||l||c.y,_t({paddingAbsolute:[!1,it.boolean],overflowBehavior:{x:["scroll","visible-hidden visible-scroll scroll hidden"],y:["scroll","visible-hidden visible-scroll scroll hidden"]}},{padding:[()=>((t,n)=>{const e=n||"",o=e+"-top",r=e+"-right",i=e+"-bottom",s=e+"-left",c=J(t,[o,r,i,s]);return{t:Y(c[o]),r:Y(c[r]),b:Y(c[i]),l:Y(c[s])}})(e,"padding"),I]},n,(t,n)=>{const{p:e,v:r}=t.paddingAbsolute,{p:i,v:c}=n.padding;if(r||c){const t={t:0,r:0,b:0,l:0};e||(t.t=-i.t,t.r=-(i.r+i.l),t.b=-(i.b+i.t),t.l=-i.l),l||(t.r-=s.S.y,t.b-=s.S.x),J(o,{top:t.t,left:t.l,"margin-right":t.r,"margin-bottom":t.b})}console.log(t),console.log(n)}));return{q:a,B:u,R:()=>{d("padding")},Y:(t,n)=>{J(r,n?{height:"auto"}:{height:"100%"})},D(){_(i)}}},xt=nt("ResizeObserver"),zt=cancelAnimationFrame,Ot=requestAnimationFrame,jt=t=>J(t,"direction"),St=(t,n,o)=>{const{G:r=!1,J:i=!1}=o||{},s=wt().k,c=S('<div class="os-size-observer"><div class="os-size-observer-listener"></div></div>')[0],l=c.firstChild,a=t=>{if(r){const t="rtl"===jt(c);f(c,t?s.n?-3333333:s.i?0:3333333:3333333),v(c,3333333)}n(e(t)?t:void 0)},u=[];let d=i?a:null;if(xt){const t=new xt(a);t.observe(l),u.push(()=>t.disconnect())}else{const t=S('<div class="os-size-observer-listener-item" dir="ltr"><div class="os-size-observer-listener-item"><div class="os-size-observer-listener-item-final"></div></div><div class="os-size-observer-listener-item"><div class="os-size-observer-listener-item-final" style="width: 200%; height: 200%"></div></div></div>');x(l,t);const n=t[0],e=n.lastChild,o=n.firstChild,r=null==o?void 0:o.firstChild;let s,c=k(l),h=c,b=!1;const p=()=>{f(o,3333333),v(o,3333333),f(e,3333333),v(e,3333333)},w=function(){s=0,b&&(c=h,a())},_=t=>(h=k(l),b=!t||!F(h,c),t&&b&&!s?(zt(s),s=Ot(w)):t||w(),p(),t&&(P(t),E(t)),!1);u.push(T(o,"scroll",_)),u.push(T(e,"scroll",_)),J(r,{width:3333333,height:3333333}),p(),d=i?()=>_():p}if(r){let t;u.push(T(c,"scroll",n=>{const e=jt(c);return e!==t&&(J(l,"rtl"===e?{left:"auto",right:0}:{left:0,right:"auto"}),t=e,a(e)),P(n),E(n),!1}))}return d&&(b(c,"os-size-observer-appear"),u.push(T(c,"animationstart",d))),z(t,c),()=>{_(u),O(c)}},$t=nt("IntersectionObserver"),At=t=>{if(function(t){const n=window.HTMLElement;return!!(c(n)||o(n)?t instanceof n:t&&c(t)&&1===t.nodeType&&e(t.nodeName))}(t)){const n=g(t,"textarea")?j():t,e=j("os-viewport"),o=j("os-content");return x(e,o),x(o,m(t)),x(t,e),b(n,"os-host"),{target:t,host:n,viewport:e,content:o}}const{host:n,viewport:r,content:i}=t;return b(n,"os-host"),b(r,"os-viewport"),b(i,"os-content"),t},kt=(t,n,e)=>{const o=At(t),r=[],{host:i}=o;r.push(yt(o));St(i,t=>{p(r,t?n=>{n.K&&n.K(t)}:t=>{t.R&&t.R()})},{J:!0,G:!0}),((t,n)=>{const e=S('<div class="os-trinsic-observer"></div>')[0],o=[];let r=!1;if($t){const i=new $t(t=>{if(t&&t.length>0){const e=t.pop();if(e){const t=e.isIntersecting||e.intersectionRatio>0;t!==r&&(n(!1,t),r=t)}}},{root:t});i.observe(e),o.push(()=>i.disconnect())}else o.push(St(e,()=>{const t=0===k(e).h;t!==r&&(n(!1,t),r=t)}));z(t,e)})(i,(t,n)=>{p(r,e=>{e.Y&&e.Y(t,n)})})};export default()=>[wt(),kt(document.body),S(' <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>')];