uv-ui
Version:
基于vue3的移动端组件库
61 lines (60 loc) • 1.76 kB
JavaScript
import { ref as s, openBlock as m, createBlock as p, Transition as u, withCtx as d, withDirectives as v, createElementVNode as a, renderSlot as k, createVNode as _, unref as h, vShow as b } from "vue";
import S from "../icon/index.js";
import { useScrollParent as T } from "../../hooks/useScrollParent.js";
import { useEventListener as w } from "../../hooks/useEventListener.js";
import { useThrottle as B } from "../../hooks/useThrottle.js";
import "../../hooks/useCountDown.js";
import { getScrollTop as y } from "../../utils/common.js";
import "./back-top.vue_vue_type_style_index_0_lang.js";
const C = { class: "uv-back-top-icon" }, N = {
name: "UvBackTop"
}, D = /* @__PURE__ */ Object.assign(N, {
props: {
immediate: {
type: Boolean,
default: !1
},
offset: {
type: Number,
default: 200
}
},
emits: ["click"],
setup(i, { emit: n }) {
const r = i, l = s(null), c = s(!1), e = T(l), f = (o) => {
var t;
n("click", o), (t = e.value) == null || t.scrollTo({
top: 0,
behavior: r.immediate ? "auto" : "smooth"
});
};
return w(e, "scroll", B(() => {
c.value = e.value ? y(e.value) >= +r.offset : !1;
})), (o, t) => (m(), p(u, { name: "back-top" }, {
default: d(() => [
v(a("div", {
class: "uv-back-top",
ref_key: "backtopRef",
ref: l,
onClick: f
}, [
k(o.$slots, "default", {}, () => [
a("div", C, [
_(h(S), {
name: "bottom",
size: 22,
color: "#fff"
})
])
])
], 512), [
[b, c.value]
])
]),
_: 3
}));
}
});
export {
D as default
};