ll-package
Version:
2 lines (1 loc) • 1.23 kB
JavaScript
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../vc-util/Dom/addEventListener.js"),u=require("../_util/supportsPassive.js");function a(i){return i!==window?i.getBoundingClientRect():{top:0,bottom:window.innerHeight}}function c(i,n,e){if(e!==void 0&&n.top>i.top-e)return`${e+n.top}px`}function l(i,n,e){if(e!==void 0&&n.bottom<i.bottom+e){const t=window.innerHeight-n.bottom;return`${e+t}px`}}const s=["resize","scroll","touchstart","touchmove","touchend","pageshow","load"];let r=[];function g(i,n){if(!i)return;let e=r.find(t=>t.target===i);e?e.affixList.push(n):(e={target:i,affixList:[n],eventHandlers:{}},r.push(e),s.forEach(t=>{e.eventHandlers[t]=f.default(i,t,()=>{e.affixList.forEach(o=>{const{lazyUpdatePosition:d}=o.exposed;d()},(t==="touchstart"||t==="touchmove")&&u.default?{passive:!0}:!1)})}))}function h(i){const n=r.find(e=>{const t=e.affixList.some(o=>o===i);return t&&(e.affixList=e.affixList.filter(o=>o!==i)),t});n&&n.affixList.length===0&&(r=r.filter(e=>e!==n),s.forEach(e=>{const t=n.eventHandlers[e];t&&t.remove&&t.remove()}))}exports.addObserveTarget=g;exports.getFixedBottom=l;exports.getFixedTop=c;exports.getTargetRect=a;exports.removeObserveTarget=h;
;