UNPKG

@getontime/cli

Version:
3 lines (2 loc) 1.5 kB
import{r as u}from"./vendor-DFNUfA2K.js";import{m as l}from"./index-BNit4nUw.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="8c2cc718-46ec-45d6-a0dd-fe8f8c84d861",t._sentryDebugIdIdentifier="sentry-dbid-8c2cc718-46ec-45d6-a0dd-fe8f8c84d861")}catch{}})();function i(t,e,n){if(!t.current||!e.current)return;const o=t.current.getBoundingClientRect(),r=e.current.getBoundingClientRect(),c=o.top-r.top+e.current.scrollTop-n;e.current.scrollTo({top:c,behavior:"smooth"})}function a(t,e,n){if(!t.current||!e.current)return;const o=t.current.getBoundingClientRect(),r=e.current.getBoundingClientRect(),c=o.top-r.top+e.current.scrollTop-n;e.current.scrollTo(e.current.scrollLeft,c)}function b(t){const{followRef:e,scrollRef:n,doFollow:o,topOffset:r=100,setScrollFlag:c}=t;return u.useEffect(()=>{o&&e.current&&n.current&&(c==null||c(!0),window.requestAnimationFrame(()=>{i(e,n,r),c==null||c(!1)}))},[e==null?void 0:e.current,n==null?void 0:n.current]),u.useCallback((s=e,d=n,f=r)=>{s.current&&d.current&&i(s,n,f)},[e,n,r])}function w(t,e=100){const n=l(),o=u.useRef(null),r=u.useRef(null);return u.useEffect(()=>{t&&n&&o.current&&r.current&&window.requestAnimationFrame(()=>{a({current:o.current},{current:r.current},e)})},[t,n,e]),{selectedRef:o,scrollRef:r}}export{w as a,b as u}; //# sourceMappingURL=useFollowComponent-2C-gde3X.js.map