UNPKG

@blossom-carousel/vue

Version:

A native-scroll-first carousel component for Vue.

49 lines (48 loc) 1.18 kB
import { shallowRef as l, onMounted as i, onBeforeUnmount as u, createBlock as c, openBlock as p, resolveDynamicComponent as d, withCtx as m, renderSlot as f } from "vue"; const y = { __name: "BlossomCarousel", props: { as: { type: String, default: "div" }, repeat: { type: Boolean, default: !1 }, load: { type: String, default: "conditional" } }, setup(t, { expose: r }) { const a = t; let e = null; const o = l(null); return r({ el: o, prev: () => e?.prev({ align: "center" }), next: () => e?.next({ align: "center" }) }), i(async () => { if (!window.matchMedia( "(hover: hover) and (pointer: fine)" ).matches && a.load !== "always") return; const { Blossom: s } = await import("@blossom-carousel/core"); e = s(o.value, { repeat: a.repeat }), e.init(); }), u(() => { e?.destroy(); }), (n, s) => (p(), c(d(t.as), { ref_key: "root", ref: o, "blossom-carousel": "true" }, { default: m(() => [ f(n.$slots, "default") ]), _: 3 }, 512)); } }; export { y as BlossomCarousel };