yamlover 0.3.52 → 0.3.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{r as i,y as C,z as R}from"./index-DosWj0lR.js";function x(s,l,f){const c=i.useRef(C()).current,a=i.useRef(null),u=i.useRef(!1),g=i.useRef(!1),m=i.useRef(0),h=e=>{const t=s.current;return e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop},d=()=>{const e=s.current,t=l();if(!e||!t.length)return 1;const n=e.getBoundingClientRect().top+e.clientHeight*.3;for(let r=0;r<t.length;r++){const o=t[r]?.getBoundingClientRect();if(o&&n<o.bottom)return r+1}return t.length},B=e=>{const t=s.current;t&&(u.current=!0,t.scrollTop=e,setTimeout(()=>u.current=!1,120))},T=e=>{const t=l();if(!t.length)return;const n=t[Math.min(Math.max(e,1),t.length)-1];n&&B(h(n))};return i.useEffect(()=>{const e=s.current;if(!e||!f)return;let t=0;const n=()=>{t||(t=requestAnimationFrame(()=>{t=0,u.current||R(d())}))};return e.addEventListener("scroll",n,{passive:!0}),()=>{e.removeEventListener("scroll",n),t&&cancelAnimationFrame(t)}},[f]),i.useEffect(()=>{if(g.current||c<=1){g.current=!0;return}if(!f)return;const e=l(),t=e[Math.min(c,e.length)-1];if(!t)return;const n=t.getBoundingClientRect().height;T(c),n>0&&n===m.current&&(g.current=!0),m.current=n}),{captureAnchor:()=>{const e=s.current,t=l();if(!e||!t.length){a.current=null;return}const n=d(),r=t[n-1],o=r?.getBoundingClientRect().height??0;a.current=r?{page:n,fraction:o?(e.scrollTop-h(r))/o:0}:null},restoreAnchor:()=>{const e=a.current;if(!e)return;let t=0,n=-1;u.current=!0;const r=()=>{const o=s.current,p=l()[e.page-1];if(!o||!p){u.current=!1;return}o.scrollTop=h(p)+e.fraction*p.getBoundingClientRect().height,Math.abs(o.scrollTop-n)>1&&t++<8?(n=o.scrollTop,requestAnimationFrame(r)):setTimeout(()=>u.current=!1,120)};r()},scrollToPage:T,initialPage:c}}function F(s,l=14,f=!0){i.useEffect(()=>{const c=s.current;if(!c||!f)return;const a=()=>{const u=c.closest(".pane"),g=c.getBoundingClientRect().top+(u?.scrollTop??0);c.style.height=`${Math.max(360,window.innerHeight-g-l)}px`};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[])}export{F as a,x as u};
1
+ import{r as i,z as B,A as C}from"./index-BVK9vlzr.js";function x(s,l,f){const c=i.useRef(B()).current,a=i.useRef(null),u=i.useRef(!1),g=i.useRef(!1),m=i.useRef(0),h=e=>{const t=s.current;return e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop},d=()=>{const e=s.current,t=l();if(!e||!t.length)return 1;const n=e.getBoundingClientRect().top+e.clientHeight*.3;for(let r=0;r<t.length;r++){const o=t[r]?.getBoundingClientRect();if(o&&n<o.bottom)return r+1}return t.length},A=e=>{const t=s.current;t&&(u.current=!0,t.scrollTop=e,setTimeout(()=>u.current=!1,120))},T=e=>{const t=l();if(!t.length)return;const n=t[Math.min(Math.max(e,1),t.length)-1];n&&A(h(n))};return i.useEffect(()=>{const e=s.current;if(!e||!f)return;let t=0;const n=()=>{t||(t=requestAnimationFrame(()=>{t=0,u.current||C(d())}))};return e.addEventListener("scroll",n,{passive:!0}),()=>{e.removeEventListener("scroll",n),t&&cancelAnimationFrame(t)}},[f]),i.useEffect(()=>{if(g.current||c<=1){g.current=!0;return}if(!f)return;const e=l(),t=e[Math.min(c,e.length)-1];if(!t)return;const n=t.getBoundingClientRect().height;T(c),n>0&&n===m.current&&(g.current=!0),m.current=n}),{captureAnchor:()=>{const e=s.current,t=l();if(!e||!t.length){a.current=null;return}const n=d(),r=t[n-1],o=r?.getBoundingClientRect().height??0;a.current=r?{page:n,fraction:o?(e.scrollTop-h(r))/o:0}:null},restoreAnchor:()=>{const e=a.current;if(!e)return;let t=0,n=-1;u.current=!0;const r=()=>{const o=s.current,p=l()[e.page-1];if(!o||!p){u.current=!1;return}o.scrollTop=h(p)+e.fraction*p.getBoundingClientRect().height,Math.abs(o.scrollTop-n)>1&&t++<8?(n=o.scrollTop,requestAnimationFrame(r)):setTimeout(()=>u.current=!1,120)};r()},scrollToPage:T,initialPage:c}}function F(s,l=14,f=!0){i.useEffect(()=>{const c=s.current;if(!c||!f)return;const a=()=>{const u=c.closest(".pane"),g=c.getBoundingClientRect().top+(u?.scrollTop??0);c.style.height=`${Math.max(360,window.innerHeight-g-l)}px`};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[])}export{F as a,x as u};