2 lines
8.5 KiB
JavaScript
2 lines
8.5 KiB
JavaScript
|
var t="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,e="undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),n=function(){if("function"==typeof requestAnimationFrame)return requestAnimationFrame.bind(e);return function(t){return setTimeout((function(){t(+Date.now())}),1e3/60)}}();var r=["top","right","bottom","left","width","height","size","weight"],i="undefined"!=typeof MutationObserver,o=t&&HTMLElement.prototype.attachShadow&&-1!==HTMLElement.prototype.attachShadow.toString().indexOf("[native code]")?HTMLElement.prototype.attachShadow:null,s=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t,e){var r=!1,i=!1,o=0;function s(){r&&(r=!1,t()),i&&c()}function a(){n(s)}function c(){var t=Date.now();if(r){if(t-o<2)return;i=!0}else r=!0,i=!1,setTimeout(a,e);o=t}return c}(this.refresh.bind(this),20)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var e=this.observers_,n=e.indexOf(t);~n&&e.splice(n,1),!e.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter((function(t){return t.gatherActive(),t.hasActive()}));return t.forEach((function(t){return t.broadcastActive()})),t.length>0},e.prototype.connect_=function(){if(t&&!this.connected_){if(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),i){this.mutationsObserver_=new MutationObserver(this.refresh);var e={attributes:!0,childList:!0,characterData:!0,subtree:!0};if(this.mutationsObserver_.observe(document,e),o){var n=this;!function t(r){var i=r.shadowRoot;i&&(n.mutationsObserver_.observe(i,e),t(i));for(var o=r.firstElementChild;o;)t(o),o=o.nextElementSibling}(document),HTMLElement.prototype.attachShadow=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=o.apply(this,t);return n.mutationsObserver_.observe(i,e),i}}}else document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0;this.connected_=!0}},e.prototype.disconnect_=function(){t&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&(this.mutationsObserver_.disconnect(),o&&(HTMLElement.prototype.attachShadow=o)),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;r.some((function(t){return!!~n.indexOf(t)}))&&this.refresh()},e.getInstance=function(){return e.instance_||(e.instance_=new e),e.instance_},e.instance_=null,e}();function a(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}var c=function(t,e){var n,r;try{for(var i=a(Object.keys(e)),o=i.next();!o.done;o=i.next()){var s=o.value;Object.defineProperty(t,s,{value:e[s],enumerable:!1,writable:!1,configurable:!0})}}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return t},h=function(t){var n;return(null===(n=null==t?void 0:t.ownerDocument)||void 0===n?void 0:n.defaultView)||e},u=_(0,0,0,0);function f(t){return"number"==typeof t?t:parseFloat(t)||0}function d(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return e.reduce((function(e,n){return e+f(t["border-"+n+"-width"])}),0)}function l(t){var e=t.clientWidth,n=t.clientHeight;if(!e&&!n)return u;var r=h(t).getComputedStyle(t),i=function(t){var e=t;return{top:f(e["padding-top"]),right:f(e["
|