UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

3 lines (2 loc) 1.52 kB
import"./column-components.b2a20dc1.js";import{useRef as e,useCallback as t,useEffect as o}from"react";import r from"ui-box";import n from"@macrostrat/hyper";var l=globalThis,i={},a={},c=l.parcelRequirea149;null==c&&((c=function(e){if(e in i)return i[e].exports;if(e in a){var t=a[e];delete a[e];var o={id:e,exports:{}};return i[e]=o,t.call(o.exports,o,o.exports),o.exports}var r=Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}).register=function(e,t){a[e]=t},l.parcelRequirea149=c),c.register,Object.defineProperty({},"ColumnScroller",{get:()=>s,set:void 0,enumerable:!0,configurable:!0});var u=c("aVUB5");function s(l){let{onScrolled:i=m,scrollContainer:a=p,scrollToHeight:c,paddingTop:s,animated:d,alignment:f,...g}=l,b=e(null),h=(0,u.useColumn)(),x=h?.scale,v=t((e,t)=>{let o=b.current;if(null==o||null==x)return;let{animated:r,alignment:n}=t;null==r&&(r=!1);let l=x(e),{top:i}=o.getBoundingClientRect();o=a();let c=l+i+s,u=window.innerHeight;"center"===n?c-=u/2:"bottom"===n&&(c-=u),r&&"scrollBehavior"in document.documentElement.style?o.scrollTo({top:c,behavior:"smooth"}):o.scrollTop=c},[i,a,b.current,x,s]);o(()=>{let{scrollToHeight:e,alignment:t}=l;if(null!=e)return v(e,{alignment:t,animated:d}),i(e)},[v,c]);let{pixelHeight:C}=this.context;return n(r,{height:C,position:"absolute",ref:b,...g})}function m(e){console.log(`Scrolled to ${e} m`)}function p(){return document.querySelector(".panel-container")}export{s as ColumnScroller}; //# sourceMappingURL=column-components.fac5b590.js.map