UNPKG

tav-ui

Version:
73 lines (70 loc) 2.19 kB
import { defineComponent, ref, unref, nextTick, resolveComponent, openBlock, createBlock, mergeProps, withCtx, renderSlot } from 'vue'; import { useScrollTo } from '../../../hooks/event/useScrollTo2.mjs'; import { TaScrollbar } from '../../scrollbar/index2.mjs'; import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.mjs'; const _sfc_main = defineComponent({ name: "TaContainerScroll", components: { Scrollbar: TaScrollbar }, setup() { const scrollbarRef = ref(null); function scrollTo(to, duration = 500) { const scrollbar = unref(scrollbarRef); if (!scrollbar) return; nextTick(() => { const wrap = unref(scrollbar.wrap); if (!wrap) return; const { start } = useScrollTo({ el: wrap, to, duration }); start(); }); } function getScrollWrap() { const scrollbar = unref(scrollbarRef); if (!scrollbar) return null; return scrollbar.wrap; } function scrollBottom() { const scrollbar = unref(scrollbarRef); if (!scrollbar) return; nextTick(() => { const wrap = unref(scrollbar.wrap); if (!wrap) return; const scrollHeight = wrap.scrollHeight; const { start } = useScrollTo({ el: wrap, to: scrollHeight }); start(); }); } return { scrollbarRef, scrollTo, scrollBottom, getScrollWrap }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_Scrollbar = resolveComponent("Scrollbar"); return openBlock(), createBlock(_component_Scrollbar, mergeProps({ ref: "scrollbarRef", "container-class": "scroll-container" }, _ctx.$attrs), { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 16); } var ContainerScroll = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/container-scroll/src/container-scroll.vue"]]); export { ContainerScroll as default }; //# sourceMappingURL=container-scroll2.mjs.map