2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
import{b as e}from"./browser-detector.d146ab9e.js";var t={exports:{}};(t.exports={}).forEach=function(e,t){for(var n=0;n<e.length;n++){var i=t(e[n]);if(i)return i}};var n={exports:{}};(n.exports={}).getOption=function(e,t,n){var i=e[t];if(null==i&&void 0!==n)return n;return i};var i=n.exports;function o(){var e={},t=0,n=0,i=0;return{add:function(o,r){r||(r=o,o=0),o>n?n=o:o<i&&(i=o),e[o]||(e[o]=[]),e[o].push(r),t++},process:function(){for(var t=i;t<=n;t++)for(var o=e[t],r=0;r<o.length;r++){(0,o[r])()}},size:function(){return t}}}var r="_erd";function a(e){return e[r]}var l={initState:function(e){return e[r]={},a(e)},getState:a,cleanState:function(e){delete e[r]}},s=e.exports,d=t.exports.forEach,c=t.exports.forEach,u=function(e){var t=e.stateHandler.getState;return{isDetectable:function(e){var n=t(e);return n&&!!n.isDetectable},markAsDetectable:function(e){t(e).isDetectable=!0},isBusy:function(e){return!!t(e).busy},markBusy:function(e,n){t(e).busy=!!n}}},f=function(e){var t={};function n(n){var i=e.get(n);return void 0===i?[]:t[i]||[]}return{get:n,add:function(n,i){var o=e.get(n);t[o]||(t[o]=[]),t[o].push(i)},removeListener:function(e,t){for(var i=n(e),o=0,r=i.length;o<r;++o)if(i[o]===t){i.splice(o,1);break}},removeAllListeners:function(e){var t=n(e);t&&(t.length=0)}}},h=function(){var e=1;return{generate:function(){return e++}}},p=function(e){var t=e.idGenerator,n=e.stateHandler.getState;return{get:function(e){var t=n(e);return t&&void 0!==t.id?t.id:null},set:function(e){var i=n(e);if(!i)throw new Error("setId required the element to have a resize detection state.");var o=t.generate();return i.id=o,o}}},m=function(e){function t(){}var n={log:t,warn:t,error:t};if(!e&&window.console){var i=function(e,t){e[t]=function(){var e=console[t];if(e.apply)e.apply(console,arguments);else for(var n=0;n<arguments.length;n++)e(arguments[n])}};i(n,"log"),i(n,"warn"),i(n,"error")}return n},g=e.exports,v=function(e){var t=(e=e||{}).reporter,n=i.getOption(e,"async",!0),r=i.getOption(e,"auto",!0);r&&!n&&(t&&t.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),n=!0);var a,l=o(),s=!1;function d(){for(s=!0;l.size();){var e=l;l=o(),e.process()}s=!1}function c(){var e;e=d,a=setTimeout(e,0)}return{add:function(e,t){!s&&r&&n&&0===l.size()&&c(),l.add(e,t)},force:function(e){s||(void 0===e&&(e=n),a&&(clearTimeout(a),a=null),e?c():d())}}},b=l,y=function(e){var t=(e=e||{}).reporter,n=e.batchProcessor,i=e.stateHandler.getState;if(!t)throw new Error("Missing required dependency: reporter.");function o(e){return i(e).object}return{makeDetectable:function(o,r,a){a||(a=r,r=o,o=null),(o=o||{}).debug,s.isIE(8)?a(r):function(r,a){var l,d,c=(l=["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"],d=e.important?" !important; ":"; ",(l.join(d)+d).trim()),u=!1,f=window.getComputedStyle(r),h=r.offsetWidth,p=r.offsetHeight;function m(){function e(){if("static"===f.position){r.style.setProperty("position","relative",o.important?"important":"");var e=function(e,t,n,i){var r=n[i];"auto"!==r&&"0"!==r.replace(/[^-\d\.]/g,"")&&(e.warn("An element that is positioned static has style."+i+"="+r+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",t),t.style.setProperty(i,"0",o.important?"important":""))};e(t,r,f,"top"),e(t,r,f,"right"),e(t,r,f,"bottom"),e(t,r,f,"left")}}""!==f.position&&(e(),u=!0);var n=document.createElement("object");n.style.cssText=c,n.tabIndex=-1,n.type="text/html",n.setAttribute("aria-hidden","true"),n.onload=function(){u||e(),function e(t,n){if(!t.contentDocument){var o=i(t);return o.checkForObjectDocumentTimeoutId&&window.clearTimeout(o.checkForObjectDocumentTimeoutId),void(o.checkForObjectDocumentTimeoutId=setTimeout((function(){o.checkForObjectDocumentTimeoutId=0,e(t,n)}),100))}n(t.contentDocument)}(this,(function(e){a(r)}))},s.isIE()||(n.data="about:blank"),i(r)&&(r.appendChild(n),i(r).object=n,s.isIE()&&(n.data="about:blank"))}i(r).startSize={width:h,height:p},n?n.add(m):m()}(r,a)},addListener:function(e,t){function n(){t(e)}if(s.isIE(8))i(e).object={proxy:n},e.attachEvent("onresize",n);else{var r=o(e);if(!r)throw new Error("Element is not detectable by this strategy.");r.contentDocument.defaultView.addEventListener("resize",n)}},uninstall:function(e){if(i(e)){var t=o(e);t&&(s.isIE(8)?e.detachEvent("onresize",t.proxy):e.removeChild(t),i(e).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(e).checkForObjectDocumentTimeoutId),delete i(e).object)}}}},w=function(e){var t=(e=e||{}).reporter,n=e.batchProcessor,i=e.stateHandler.getState;e.stateHandler.hasState;var o=e.idHandler;if(!n)throw new Error("Missing required dependency: batchProcessor");if(!t)throw new Error("Missing required dependency: reporter.");var r=function(){var e=500,t=500,n=document.createElement("div");n.style.cssText=s(["position: absolute","width: 1000px","height: 1000px","visibility: hidden","margin: 0","padding: 0"]);var i=document.createElement("div");i.style.cssText=s(["position: absolute","width: 500px","height: 500px","overflow: scroll","visibility: none","top: -1500px","left: -1500px","visibility: hidden","margin: 0","padding: 0"]),i.appendChild(n),document.body.insertBefore(i,document.body.firstChild);var o=e-i.clientWidth,r=t-i.clientHeight;return document.body.removeChild(i),{width:o,height:r}}(),a="erd_scroll_detection_container";function l(e){!function(e,t,n){function i(n,i){i=i||function(t){e.head.appendChild(t)};var o=e.createElement("style");return o.innerHTML=n,o.id=t,i(o),o}if(!e.getElementById(t)){var o=n+"_animation",r=n+"_animation_active",a="/* Created by the element-resize-detector library. */\n";a+="."+n+" > div::-webkit-scrollbar { "+s(["display: none"])+" }\n\n",a+="."+r+" { "+s(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+o,"animation-name: "+o])+" }\n",a+="@-webkit-keyframes "+o+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }\n",i(a+="@keyframes "+o+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }")}}(e,"erd_scroll_detection_scrollbar_style",a)}function s(t){var n=e.important?" !important; ":"; ";return(t.join(n)+n).trim()}function c(e,n,i){if(e.addEventListener)e.addEventListener(n,i);else{if(!e.attachEvent)return t.error("[scroll] Don't know how to add event listeners.");e.attachEvent("on"+n,i)}}function u(e,n,i){if(e.removeEventListener)e.removeEventListener(n,i);else{if(!e.detachEvent)return t.error("[scroll] Don't know how to remove event listeners.");e.detachEvent("on"+n,i)}}function f(e){return i(e).container.childNodes[0].childNodes[0].childNodes[0]}function h(e){return i(e).container.childNodes[0].childNodes[0].childNodes[1]}return l(window.document),{makeDetectable:function(e,l,u){function p(){if(e.debug){var n=Array.prototype.slice.call(arguments);if(n.unshift(o.get(l),"Scroll: "),t.log.apply)t.log.apply(null,n);else for(var i=0;i<n.length;i++)t.log(n[i])}}function m(e){var t=i(e).container.childNodes[0],n=window.getComputedStyle(t);return!n.width||-1===n.width.indexOf("px")}function g(){var e=window.getComputedStyle(l),t={};return t.position=e.position,t.width=l.offsetWidth,t.height=l.offsetHeight,t.top=e.top,t.right=e.right,t.bottom=e.bottom,t.left=e.left,t.widthCSS=e.width,t.heightCSS=e.height,t}function v(){if(p("storeStyle invoked."),i(l)){var e=g();i(l).style=e}else p("Aborting because element has been uninstalled")}function b(e,t,n){i(e).lastWidth=t,i(e).lastHeight=n}function y(){return 2*r.width+1}function w(){return 2*r.height+1}function x(e){return e+10+y()}function E(e){return e+10+w()}function S(e,t,n){var i=f(e),o=h(e),r=x(t),a=E(n),l=function(e){return 2*e+y()}(t),s=function(e){return 2*e+w()}(n);i.scrollLeft=r,i.scrollTop=a,o.scrollLeft=l,o.scrollTop=s}function k(){var e=i(l).container;if(!e){(e=document.createElement("div")).className=a,e.style.cssText=s(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),i(l).container=e,function(e){e.className+=" "+a+"_animation_active"}(e),l.appendChild(e);var t=function(){i(l).onRendered&&i(l).onRendered()};c(e,"animationstart",t),i(l).onAnimationStart=t}return e}function A(){if(p("Injecting elements"),i(l)){!function(){var n=i(l).style;if("static"===n.position){l.style.setProperty("position","relative",e.important?"important":"");var o=function(e,t,n,i){var o=n[i];"auto"!==o&&"0"!==o.replace(/[^-\d\.]/g,"")&&(e.warn("An element that is positioned static has style."+i+"="+o+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",t),t.style[i]=0)};o(t,l,n,"top"),o(t,l,n,"right"),o(t,l,n,"bottom"),o(t,l,n,"left")}}();var n=i(l).container;n||(n=k());var o,d,u,f,h=r.width,m=r.height,g=s(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),v=s(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(["left: "+(o=(o=-(1+h))?o+"px":"0"),"top: "+(d=(d=-(1+m))?d+"px":"0"),"right: "+(f=(f=-h)?f+"px":"0"),"bottom: "+(u=(u=-m)?u+"px":"0")])),b=s(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),y=s(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),w=s(["position: absolute","left: 0","top: 0"]),x=s(["position: absolute","width: 200%","height: 200%"]),E=document.createElement("div"),S=document.createElement("div"),A=document.createElement("div"),z=document.createElement("div"),D=document.createElement("div"),T=document.createElement("div");E.dir="ltr",E.style.cssText=g,E.className=a,S.className=a,S.style.cssText=v,A.style.cssText=b,z.style.cssText=w,D.style.cssText=y,T.style.cssText=x,A.appendChild(z),D.appendChild(T),S.appendChild(A),S.appendChild(D),E.appendChild(S),n.appendChild(E),c(A,"scroll",H),c(D,"scroll",C),i(l).onExpandScroll=H,i(l).onShrinkScroll=C}else p("Aborting because element has been uninstalled");function H(){var e=i(l);e&&e.onExpand?e.onExpand():p("Aborting expand scroll handler: element has been uninstalled")}function C(){var e=i(l);e&&e.onShrink?e.onShrink():p("Aborting shrink scroll handler: element has been uninstalled")}}function z(){function r(t,n,i){var o=function(e){return f(e).childNodes[0]}(t),r=x(n),a=E(i);o.style.setProperty("width",r+"px",e.important?"important":""),o.style.setProperty("height",a+"px",e.important?"important":"")}function a(a){var d=l.offsetWidth,c=l.offsetHeight,u=d!==i(l).lastWidth||c!==i(l).lastHeight;p("Storing current size",d,c),b(l,d,c),n.add(0,(function(){if(u)if(i(l))if(s()){if(e.debug){var n=l.offsetWidth,a=l.offsetHeight;n===d&&a===c||t.warn(o.get(l),"Scroll: Size changed before updating detector elements.")}r(l,d,c)}else p("Aborting because element container has not been initialized");else p("Aborting because element has been uninstalled")})),n.add(1,(function(){i(l)?s()?S(l,d,c):p("Aborting because element container has not been initialized"):p("Aborting because element has been uninstalled")})),u&&a&&n.add(2,(function(){i(l)?s()?a():p("Aborting because element container has not been initialized"):p("Aborting because element has been uninstalled")}))}function s(){return!!i(l).container}function c(){p("notifyListenersIfNeeded invoked");var e=i(l);return void 0===i(l).lastNotifiedWidth&&e.lastWidth===e.startSize.width&&e.lastHeight===e.startSize.height?p("Not notifying: Size is the same as the start size, and there has been no notification yet."):e.lastWidth===e.lastNotifiedWidth&&e.lastHeight===e.lastNotifiedHeight?p("Not notifying: Size already notified"):(p("Current size not notified, notifying..."),e.lastNotifiedWidth=e.lastWidth,e.lastNotifiedHeight=e.lastHeight,void d(i(l).listeners,(function(e){e(l)})))}function u(){p("Scroll detected."),m(l)?p("Scroll event fired while unrendered. Ignoring..."):a(c)}if(p("registerListenersAndPositionElements invoked."),i(l)){i(l).onRendered=function(){if(p("startanimation triggered."),m(l))p("Ignoring since element is still unrendered...");else{p("Element rendered.");var e=f(l),t=h(l);0!==e.scrollLeft&&0!==e.scrollTop&&0!==t.scrollLeft&&0!==t.scrollTop||(p("Scrollbars out of sync. Updating detector elements..."),a(c))}},i(l).onExpand=u,i(l).onShrink=u;var g=i(l).style;r(l,g.width,g.height)}else p("Aborting because element has been uninstalled")}function D(){if(p("finalizeDomMutation invoked."),i(l)){var e=i(l).style;b(l,e.width,e.height),S(l,e.width,e.height)}else p("Aborting because element has been uninstalled")}function T(){u(l)}function H(){var e;p("Installing..."),i(l).listeners=[],e=g(),i(l).startSize={width:e.width,height:e.height},p("Element start size",i(l).startSize),n.add(0,v),n.add(1,A),n.add(2,z),n.add(3,D),n.add(4,T)}var C,I,L;u||(u=l,l=e,e=null),e=e||{},p("Making detectable..."),L=(I=C=l).getRootNode&&I.getRootNode().contains(I),I!==I.ownerDocument.body&&!I.ownerDocument.body.contains(I)&&!L||null===window.getComputedStyle(C)?(p("Element is detached"),k(),p("Waiting until element is attached..."),i(l).onRendered=function(){p("Element is now attached"),H()}):H()},addListener:function(e,t){if(!i(e).listeners.push)throw new Error("Cannot add listener to an element that is not detectable.");i(e).listeners.push(t)},uninstall:function(e){var t=i(e);t&&(t.onExpandScroll&&u(f(e),"scroll",t.onExpandScroll),t.onShrinkScroll&&u(h(e),"scroll",t.onShrinkScroll),t.onAnimationStart&&u(t.container,"animationstart",t.onAnimationStart),t.container&&e.removeChild(t.container))},initDocument:l}};function x(e){return Array.isArray(e)||void 0!==e.length}function E(e){if(Array.isArray(e))return e;var t=[];return c(e,(function(e){t.push(e)})),t}function S(e){return e&&1===e.nodeType}var k=function(e){var t;if((e=e||{}).idHandler)t={get:function(t){return e.idHandler.get(t,!0)},set:e.idHandler.set};else{var n=h(),i=p({idGenerator:n,stateHandler:b});t=i}var o=e.reporter;o||(o=m(!1===o));var r=A(e,"batchProcessor",v({reporter:o})),a={};a.callOnAdd=!!A(e,"callOnAdd",!0),a.debug=!!A(e,"debug",!1);var l,s=f(t),d=u({stateHandler:b}),k=A(e,"strategy","object"),z=A(e,"important",!1),D={reporter:o,batchProcessor:r,stateHandler:b,idHandler:t,important:z};if("scroll"===k&&(g.isLegacyOpera()?(o.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),k="object"):g.isIE(9)&&(o.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),k="object")),"scroll"===k)l=w(D);else{if("object"!==k)throw new Error("Invalid strategy name: "+k);l=y(D)}var T={};return{listenTo:function(e,n,i){function r(e){var t=s.get(e);c(t,(function(t){t(e)}))}function u(e,t,n){s.add(t,n),e&&n(t)}if(i||(i=n,n=e,e={}),!n)throw new Error("At least one element required.");if(!i)throw new Error("Listener required.");if(S(n))n=[n];else{if(!x(n))return o.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");n=E(n)}var f=0,h=A(e,"callOnAdd",a.callOnAdd),p=A(e,"onReady",(function(){})),m=A(e,"debug",a.debug);c(n,(function(e){b.getState(e)||(b.initState(e),t.set(e));var a=t.get(e);if(m&&o.log("Attaching listener to element",a,e),!d.isDetectable(e))return m&&o.log(a,"Not detectable."),d.isBusy(e)?(m&&o.log(a,"System busy making it detectable"),u(h,e,i),T[a]=T[a]||[],void T[a].push((function(){++f===n.length&&p()}))):(m&&o.log(a,"Making detectable..."),d.markBusy(e,!0),l.makeDetectable({debug:m,important:z},e,(function(e){if(m&&o.log(a,"onElementDetectable"),b.getState(e)){d.markAsDetectable(e),d.markBusy(e,!1),l.addListener(e,r),u(h,e,i);var t=b.getState(e);if(t&&t.startSize){var s=e.offsetWidth,g=e.offsetHeight;t.startSize.width===s&&t.startSize.height===g||r(e)}T[a]&&c(T[a],(function(e){e()}))}else m&&o.log(a,"Element uninstalled before being detectable.");delete T[a],++f===n.length&&p()})));m&&o.log(a,"Already detecable, adding listener."),u(h,e,i),f++})),f===n.length&&p()},removeListener:s.removeListener,removeAllListeners:s.removeAllListeners,uninstall:function(e){if(!e)return o.error("At least one element is required.");if(S(e))e=[e];else{if(!x(e))return o.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");e=E(e)}c(e,(function(e){s.removeAllListeners(e),l.uninstall(e),b.cleanState(e)}))},initDocument:function(e){l.initDocument&&l.initDocument(e)}}};function A(e,t,n){var i=e[t];return null==i&&void 0!==n?n:i}export{k as e};
|