UNPKG

@opensig/opendesign

Version:

91 lines (90 loc) 2.69 kB
import { defineComponent, ref, createElementBlock, openBlock, createElementVNode, createVNode, normalizeClass, unref, renderSlot, withCtx } from "vue"; import _sfc_main$1 from "./OScrollbar.vue.mjs"; import { scrollerProps } from "./types.mjs"; import { mergeClass } from "../_utils/vue-utils.mjs"; const _hoisted_1 = { class: "o-scroller o-scrollbar-wrapper" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "OScroller", props: scrollerProps, emits: ["scroll"], setup(__props, { expose: __expose, emit: __emit }) { const props = __props; const emits = __emit; const targetRef = ref(null); const scrollTo = (options) => { if (!targetRef.value) { return; } targetRef.value.scrollTo(options); }; const scrollBy = (options) => { if (!targetRef.value) { return; } targetRef.value.scrollBy(options); }; __expose({ scrollTo, /** * 按偏移量滚动 * @since 1.2.4 */ scrollBy, /** * 获取容器DOM元素 */ getContainerEl() { return targetRef.value; } }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode( "div", { ref_key: "targetRef", ref: targetRef, class: normalizeClass( unref(mergeClass)( "o-scroller-container", { "is-x-disabled": props.disabledX, "is-y-disabled": props.disabledY }, props.wrapClass ) ), onScrollPassive: _cache[0] || (_cache[0] = (e) => emits("scroll", e)) }, [ renderSlot(_ctx.$slots, "default") ], 34 /* CLASS, NEED_HYDRATION */ ), createVNode(_sfc_main$1, { target: targetRef.value, "disabled-x": props.disabledX, "disabled-y": props.disabledY, duration: props.duration, "show-type": props.showType, size: props.size, "bar-class": props.barClass, "auto-update-on-scroll-size": props.autoUpdateOnScrollSize }, { thumb: withCtx(() => [ renderSlot(_ctx.$slots, "thumb") ]), track: withCtx(() => [ renderSlot(_ctx.$slots, "track") ]), _: 3 /* FORWARDED */ }, 8, ["target", "disabled-x", "disabled-y", "duration", "show-type", "size", "bar-class", "auto-update-on-scroll-size"]) ]); }; } }); export { _sfc_main as default };