UNPKG

tav-ui

Version:
28 lines (25 loc) 744 B
import { useScrollTo } from './useScrollTo2.mjs'; const useScrollToCenter = (scrollRef, opt = {}) => { let currentStopFn; const scrollToCenter = (buttonEl) => { currentStopFn?.(); const buttonGroupEl = scrollRef.value?.$el ?? scrollRef.value; if (buttonGroupEl == void 0) return; if (buttonEl === void 0) return; const to = buttonEl.offsetLeft - (buttonGroupEl.clientWidth - buttonEl.offsetWidth) / 2; const { start, stop } = useScrollTo({ el: buttonGroupEl, to, direction: "scrollLeft", duration: 300, ...opt }); start(); currentStopFn = stop; }; return { scrollToCenter }; }; export { useScrollToCenter }; //# sourceMappingURL=useScrollToCenter2.mjs.map