UNPKG

compute-scroll-into-view

Version:

The engine that powers scroll-into-view-if-needed

2 lines • 934 B
const e=e=>({top:e(`top`,!0,`y`),right:e(`right`,!1,`x`),bottom:e(`bottom`,!1,`y`),left:e(`left`,!0,`x`)}),t=(t,n,r)=>e((e,i)=>t[e]+(i?r:-r)*n[e]),n=(e,t)=>t&&e===`hidden`?!1:e!==`visible`&&e!==`clip`,r=e=>{try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}},i=e=>{let{documentElement:t,scrollingElement:n}=e.ownerDocument,i=r(e);return!!i&&(e===t||e===n)&&(i.clientHeight<e.scrollHeight||i.clientWidth<e.scrollWidth)},a=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){let r=getComputedStyle(e);return n(r.overflowY,t)||n(r.overflowX,t)||i(e)}return!1},o=e=>`host`in e,s=e=>`assignedSlot`in e,c=e=>{let t=s(e)&&e.assignedSlot||e.parentElement;if(t==null){let t=e.getRootNode();return o(t)&&t.host||null}return t},l=({scrollport:e,scrollPadding:n})=>t(e,n,1),u=({target:e,scrollMargin:n})=>t(e,n,-1);export{a,u as i,c as n,e as o,l as r,r as t}; //# sourceMappingURL=shared-td4zZn_K.js.map