1 line
9.3 KiB
JavaScript
1 line
9.3 KiB
JavaScript
![]() |
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):global.ResizeObserver=factory()}(this,function(){"use strict";function getHTMLElementContentRect(target){var rect=target.getBoundingClientRect();return createRectInit(rect.left,rect.top,rect.width,rect.height)}function getContentRect(target){return isBrowser?getHTMLElementContentRect(target):emptyRect}function createReadOnlyRect(ref){var x=ref.x,y=ref.y,width=ref.width,height=ref.height,Constr="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,rect=Object.create(Constr.prototype);return defineConfigurable(rect,{x:x,y:y,width:width,height:height,top:y,right:x+width,bottom:height+y,left:x}),rect}function createRectInit(x,y,width,height){return{x:x,y:y,width:width,height:height}}var MapShim=function(){function getIndex(arr,key){var result=-1;return arr.some(function(entry,index){return entry[0]===key&&(result=index,!0)}),result}return"undefined"!=typeof Map?Map:function(){function anonymous(){this.__entries__=[]}var prototypeAccessors={size:{configurable:!0}};return prototypeAccessors.size.get=function(){return this.__entries__.length},anonymous.prototype.get=function(key){var index=getIndex(this.__entries__,key),entry=this.__entries__[index];return entry&&entry[1]},anonymous.prototype.set=function(key,value){var index=getIndex(this.__entries__,key);~index?this.__entries__[index][1]=value:this.__entries__.push([key,value])},anonymous.prototype.delete=function(key){var entries=this.__entries__,index=getIndex(entries,key);~index&&entries.splice(index,1)},anonymous.prototype.has=function(key){return!!~getIndex(this.__entries__,key)},anonymous.prototype.clear=function(){this.__entries__.splice(0)},anonymous.prototype.forEach=function(callback,ctx){var this$1=this;void 0===ctx&&(ctx=null);for(var i=0,list=this$1.__entries__;i<list.length;i+=1){var entry=list[i];callback.call(ctx,entry[1],entry[0])}},Object.defineProperties(anonymous.prototype,prototypeAccessors),anonymous}()}(),isBrowser="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,global$1=function(){return"undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")()}(),requestAnimationFrame$1=function(){return"function"==typeof requestAnimationFrame?requestAnimationFrame.bind(global$1):function(callback){return setTimeout(function(){return callback(Date.now())},1e3/60)}}(),trailingTimeout=2,throttle=function(callback,delay){function resolvePending(){leadingCall&&(leadingCall=!1,callback()),trailingCall&&proxy()}function timeoutCallback(){requestAnimationFrame$1(resolvePending)}function proxy(){var timeStamp=Date.now();if(leadingCall){if(timeStamp-lastCallTime<trailingTimeout)return;trailingCall=!0}else leadingCall=!0,trailingCall=!1,setTimeout(timeoutCallback,delay);lastCallTime=timeStamp}var leadingCall=!1,trailingCall=!1,lastCallTime=0;return proxy},transitionKeys=["top","right","bottom","left","width","height","size","weight"],mutationObserverSupported="undefined"!=typeof MutationObserver,ResizeObserverController=function(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=throttle(this.refresh.bind(this),20)};ResizeObserverController.prototype.addObserver=function(observer){~this.observers_.indexOf(observer)||this.observers_.push(observer),this.connected_||this.connect_()},ResizeObserverController.prototype.removeObserver=function(observer){var observers=this.observers_,index=observers.indexOf(observer);~index&&observers.splice(index,1),!observers.length&&this.connected_&&this.disconnect_()},ResizeObserverController.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},ResizeObserverController.prototype.updateObservers_=function(){var activeObservers=this.observers_.filter(function(observer){return observer.gatherActive(),ob
|