mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-03 02:36:39 +08:00
1 line
8.0 KiB
JavaScript
1 line
8.0 KiB
JavaScript
(window["RCDLjsonFunction"]=window["RCDLjsonFunction"]||[]).push([[126],{259:function(t,e){(function(){"use strict";if(typeof window!=="object"){return}if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in window.IntersectionObserverEntry.prototype){if(!("isIntersecting"in window.IntersectionObserverEntry.prototype)){Object.defineProperty(window.IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}})}return}var t=window.document;var e=[];function IntersectionObserverEntry(t){this.time=t.time;this.target=t.target;this.rootBounds=t.rootBounds;this.boundingClientRect=t.boundingClientRect;this.intersectionRect=t.intersectionRect||getEmptyRect();this.isIntersecting=!!t.intersectionRect;var e=this.boundingClientRect;var n=e.width*e.height;var r=this.intersectionRect;var i=r.width*r.height;if(n){this.intersectionRatio=Number((i/n).toFixed(4))}else{this.intersectionRatio=this.isIntersecting?1:0}}function IntersectionObserver(t,e){var n=e||{};if(typeof t!="function"){throw new Error("callback must be a function")}if(n.root&&n.root.nodeType!=1){throw new Error("root must be an Element")}this._checkForIntersections=throttle(this._checkForIntersections.bind(this),this.THROTTLE_TIMEOUT);this._callback=t;this._observationTargets=[];this._queuedEntries=[];this._rootMarginValues=this._parseRootMargin(n.rootMargin);this.thresholds=this._initThresholds(n.threshold);this.root=n.root||null;this.rootMargin=this._rootMarginValues.map((function(t){return t.value+t.unit})).join(" ")}IntersectionObserver.prototype.THROTTLE_TIMEOUT=100;IntersectionObserver.prototype.POLL_INTERVAL=null;IntersectionObserver.prototype.USE_MUTATION_OBSERVER=true;IntersectionObserver.prototype.observe=function(t){var e=this._observationTargets.some((function(e){return e.element==t}));if(e){return}if(!(t&&t.nodeType==1)){throw new Error("target must be an Element")}this._registerInstance();this._observationTargets.push({element:t,entry:null});this._monitorIntersections();this._checkForIntersections()};IntersectionObserver.prototype.unobserve=function(t){this._observationTargets=this._observationTargets.filter((function(e){return e.element!=t}));if(!this._observationTargets.length){this._unmonitorIntersections();this._unregisterInstance()}};IntersectionObserver.prototype.disconnect=function(){this._observationTargets=[];this._unmonitorIntersections();this._unregisterInstance()};IntersectionObserver.prototype.takeRecords=function(){var t=this._queuedEntries.slice();this._queuedEntries=[];return t};IntersectionObserver.prototype._initThresholds=function(t){var e=t||[0];if(!Array.isArray(e))e=[e];return e.sort().filter((function(t,e,n){if(typeof t!="number"||isNaN(t)||t<0||t>1){throw new Error("threshold must be a number between 0 and 1 inclusively")}return t!==n[e-1]}))};IntersectionObserver.prototype._parseRootMargin=function(t){var e=t||"0px";var n=e.split(/\s+/).map((function(t){var e=/^(-?\d*\.?\d+)(px|%)$/.exec(t);if(!e){throw new Error("rootMargin must be specified in pixels or percent")}return{value:parseFloat(e[1]),unit:e[2]}}));n[1]=n[1]||n[0];n[2]=n[2]||n[0];n[3]=n[3]||n[1];return n};IntersectionObserver.prototype._monitorIntersections=function(){if(!this._monitoringIntersections){this._monitoringIntersections=true;if(this.POLL_INTERVAL){this._monitoringInterval=setInterval(this._checkForIntersections,this.POLL_INTERVAL)}else{addEvent(window,"resize",this._checkForIntersections,true);addEvent(t,"scroll",this._checkForIntersections,true);if(this.USE_MUTATION_OBSERVER&&"MutationObserver"in window){this._domObserver=new MutationObserver(this._checkForIntersections);this._domObserver.observe(t,{attributes:true,childList:true,characterData:true,subtree:true})}}}};IntersectionObserver.prototype._unmonitorIntersections=function(){if(this._monitoringIntersections){this._monitoringIntersections=false;clearInterval(this._monitoringInterval);this._monitoringInterval=null;removeEvent(window,"resize",this._checkForIntersections,true);removeEvent(t,"scroll",this._checkForIntersections,true);if(this._domObserver){this._domObserver.disconnect();this._domObserver=null}}};IntersectionObserver.prototype._checkForIntersections=function(){var t=this._rootIsInDom();var e=t?this._getRootRect():getEmptyRect();this._observationTargets.forEach((function(n){var r=n.element;var i=getBoundingClientRect(r);var o=this._rootContainsTarget(r);var s=n.entry;var c=t&&o&&this._computeTargetAndRootIntersection(r,e);var h=n.entry=new IntersectionObserverEntry({time:now(),target:r,boundingClientRect:i,rootBounds:e,intersectionRect:c});if(!s){this._queuedEntries.push(h)}else if(t&&o){if(this._hasCrossedThreshold(s,h)){this._queuedEntries.push(h)}}else{if(s&&s.isIntersecting){this._queuedEntries.push(h)}}}),this);if(this._queuedEntries.length){this._callback(this.takeRecords(),this)}};IntersectionObserver.prototype._computeTargetAndRootIntersection=function(e,n){if(window.getComputedStyle(e).display=="none")return;var r=getBoundingClientRect(e);var i=r;var o=getParentNode(e);var s=false;while(!s){var c=null;var h=o.nodeType==1?window.getComputedStyle(o):{};if(h.display=="none")return;if(o==this.root||o==t){s=true;c=n}else{if(o!=t.body&&o!=t.documentElement&&h.overflow!="visible"){c=getBoundingClientRect(o)}}if(c){i=computeRectIntersection(c,i);if(!i)break}o=getParentNode(o)}return i};IntersectionObserver.prototype._getRootRect=function(){var e;if(this.root){e=getBoundingClientRect(this.root)}else{var n=t.documentElement;var r=t.body;e={top:0,left:0,right:n.clientWidth||r.clientWidth,width:n.clientWidth||r.clientWidth,bottom:n.clientHeight||r.clientHeight,height:n.clientHeight||r.clientHeight}}return this._expandRectByRootMargin(e)};IntersectionObserver.prototype._expandRectByRootMargin=function(t){var e=this._rootMarginValues.map((function(e,n){return e.unit=="px"?e.value:e.value*(n%2?t.width:t.height)/100}));var n={top:t.top-e[0],right:t.right+e[1],bottom:t.bottom+e[2],left:t.left-e[3]};n.width=n.right-n.left;n.height=n.bottom-n.top;return n};IntersectionObserver.prototype._hasCrossedThreshold=function(t,e){var n=t&&t.isIntersecting?t.intersectionRatio||0:-1;var r=e.isIntersecting?e.intersectionRatio||0:-1;if(n===r)return;for(var i=0;i<this.thresholds.length;i++){var o=this.thresholds[i];if(o==n||o==r||o<n!==o<r){return true}}};IntersectionObserver.prototype._rootIsInDom=function(){return!this.root||containsDeep(t,this.root)};IntersectionObserver.prototype._rootContainsTarget=function(e){return containsDeep(this.root||t,e)};IntersectionObserver.prototype._registerInstance=function(){if(e.indexOf(this)<0){e.push(this)}};IntersectionObserver.prototype._unregisterInstance=function(){var t=e.indexOf(this);if(t!=-1)e.splice(t,1)};function now(){return window.performance&&performance.now&&performance.now()}function throttle(t,e){var n=null;return function(){if(!n){n=setTimeout((function(){t();n=null}),e)}}}function addEvent(t,e,n,r){if(typeof t.addEventListener=="function"){t.addEventListener(e,n,r||false)}else if(typeof t.attachEvent=="function"){t.attachEvent("on"+e,n)}}function removeEvent(t,e,n,r){if(typeof t.removeEventListener=="function"){t.removeEventListener(e,n,r||false)}else if(typeof t.detatchEvent=="function"){t.detatchEvent("on"+e,n)}}function computeRectIntersection(t,e){var n=Math.max(t.top,e.top);var r=Math.min(t.bottom,e.bottom);var i=Math.max(t.left,e.left);var o=Math.min(t.right,e.right);var s=o-i;var c=r-n;return s>=0&&c>=0&&{top:n,bottom:r,left:i,right:o,width:s,height:c}}function getBoundingClientRect(t){var e;try{e=t.getBoundingClientRect()}catch(t){}if(!e)return getEmptyRect();if(!(e.width&&e.height)){e={top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.right-e.left,height:e.bottom-e.top}}return e}function getEmptyRect(){return{top:0,bottom:0,left:0,right:0,width:0,height:0}}function containsDeep(t,e){var n=e;while(n){if(n==t)return true;n=getParentNode(n)}return false}function getParentNode(t){var e=t.parentNode;if(e&&e.nodeType==11&&e.host){return e.host}if(e&&e.assignedSlot){return e.assignedSlot.parentNode}return e}window.IntersectionObserver=IntersectionObserver;window.IntersectionObserverEntry=IntersectionObserverEntry})()}}]); |