@loickit-v/swiper
Version:
loickit swiper components for vue
70 lines (69 loc) • 1.87 kB
JavaScript
import { defineComponent as a, watch as c, ref as f, onMounted as m, onBeforeUnmount as p, createElementBlock as u, openBlock as h, createElementVNode as x, renderSlot as v } from "vue";
import { useSlideState as I } from "../Provide/index.js";
import { useSlidePrivateState as w } from "../Slide/provide.js";
const C = /* @__PURE__ */ a({
name: "LSlideItem",
__name: "index",
props: {
index: {}
},
setup(l) {
const i = l, e = w();
if (e.infinite && typeof i.index != "number")
throw new Error(
`index is required when infinite is true
please use the second parameter of the "v-for" directive`
);
const r = I(e.name);
e.infinite && c(
() => r.currentIndex,
() => {
var t;
r.currentIndex <= i.index + 1 && r.currentIndex >= i.index - 1 ? (t = o.value) == null || t.appendChild(
e.itemsInfo[i.index].el
) : s.value.remove();
}
);
const o = f(), s = f(), n = {
index: i.index
};
return m(() => {
var d;
const t = (d = o.value) == null ? void 0 : d.getBoundingClientRect();
n.width = t.width, n.height = t.height, e.infinite && (n.el = s.value), e.itemsInfo.push(n);
}), p(() => {
e.itemsInfo.splice(
e.itemsInfo.indexOf(n),
1
);
}), (t, d) => (h(), u(
"div",
{
ref_key: "slideItemRef",
ref: o,
class: "loickit-slide-item",
style: { position: "relative" }
},
[
x(
"div",
{
ref_key: "slideItemContentWrapperRef",
ref: s,
class: "loickit-slide-item-content-wrapper"
},
[
v(t.$slots, "default")
],
512
/* NEED_PATCH */
)
],
512
/* NEED_PATCH */
));
}
});
export {
C as default
};