@blossom-carousel/vue
Version:
A native-scroll-first carousel component for Vue.
45 lines (44 loc) • 1.07 kB
JavaScript
import { shallowRef as r, onMounted as u, onBeforeUnmount as i, 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: n }) {
const s = t, e = r(null);
n({ el: e });
let o = null;
return u(async () => {
if (!window.matchMedia(
"(hover: hover) and (pointer: fine)"
).matches && s.load !== "always") return;
const { Blossom: l } = await import("@blossom-carousel/core");
o = l(e.value, { repeat: s.repeat }), o.init();
}), i(() => {
o?.destroy();
}), (a, l) => (p(), c(d(t.as), {
ref_key: "root",
ref: e,
"blossom-carousel": "true"
}, {
default: m(() => [
f(a.$slots, "default")
]),
_: 3
}, 512));
}
};
export {
y as BlossomCarousel
};