tttb 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tttb might be problematic. Click here for more details.
|
@@ -1,128 +1,113 @@
|
|
|
1
|
-
import { render as
|
|
2
|
-
import { debounce as
|
|
1
|
+
import { render as v, h } from "vue";
|
|
2
|
+
import { debounce as f } from "../utils/debounce.js";
|
|
3
3
|
import "../utils/dialog.js";
|
|
4
|
-
import { injectStyles as
|
|
4
|
+
import { injectStyles as u } from "../utils/injectStyles.js";
|
|
5
5
|
import "../utils/localStorage.js";
|
|
6
6
|
import "../utils/msg.js";
|
|
7
7
|
import "../utils/sessionStorage.js";
|
|
8
|
-
import { DEFAULT_OPTIONS as
|
|
9
|
-
import
|
|
10
|
-
import { faAngleUp as
|
|
11
|
-
import
|
|
12
|
-
const
|
|
8
|
+
import { DEFAULT_OPTIONS as m } from "../hooks/useWindowBackTop.js";
|
|
9
|
+
import y from "../components/Icon/index.js";
|
|
10
|
+
import { faAngleUp as w } from "../node_modules/@fortawesome/free-solid-svg-icons/index.js";
|
|
11
|
+
import l from "../node_modules/gsap/index.js";
|
|
12
|
+
const g = `
|
|
13
13
|
.v-back-top-wrapper {
|
|
14
|
-
position:
|
|
15
|
-
top: 0;
|
|
14
|
+
position: sticky;
|
|
16
15
|
left: 0;
|
|
17
|
-
|
|
16
|
+
bottom: 0;
|
|
17
|
+
width: 100%;
|
|
18
18
|
height: 0;
|
|
19
|
-
|
|
19
|
+
pointer-events: none;
|
|
20
20
|
}
|
|
21
|
+
|
|
21
22
|
.v-back-top-inner {
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
--size: var(--vbt-size, 36px);
|
|
24
|
+
position: absolute;
|
|
25
|
+
width: var(--size);
|
|
26
|
+
height: var(--size);
|
|
24
27
|
color: var(--color-white, #fff);
|
|
25
|
-
font-size: calc(var(--size
|
|
28
|
+
font-size: calc(var(--size) * 0.5);
|
|
26
29
|
border-radius: 50%;
|
|
27
30
|
display: none;
|
|
28
31
|
align-items: center;
|
|
29
32
|
justify-content: center;
|
|
30
33
|
cursor: pointer;
|
|
31
|
-
|
|
34
|
+
pointer-events: auto;
|
|
35
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
36
|
+
will-change: transform, opacity;
|
|
32
37
|
}
|
|
38
|
+
|
|
33
39
|
.v-back-top-inner:hover {
|
|
34
40
|
filter: brightness(1.1);
|
|
41
|
+
transform: translateY(-2px);
|
|
35
42
|
}
|
|
36
43
|
`;
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const o =
|
|
40
|
-
o.
|
|
41
|
-
|
|
42
|
-
return i.className = `v-back-top-inner bg-${t.type}`, i.style.setProperty("--size", `${t.size}px`), i.title = "回到顶部", g(b(x, { icon: O }), i), i.addEventListener("click", (r) => {
|
|
43
|
-
r.stopPropagation(), e.scrollTo({ top: 0, behavior: "smooth" });
|
|
44
|
-
}), o.appendChild(i), e.appendChild(o), { wrapper: o, inner: i };
|
|
45
|
-
}, l = (e) => {
|
|
46
|
-
const { el: t, wrapper: o, clientHeight: i, clientWidth: r, options: s } = e, c = t.scrollTop + i - s.size - s.bottom, a = t.scrollLeft + r - s.size - s.right;
|
|
47
|
-
o.style.transform = `translate3d(${a}px, ${c}px, 0)`;
|
|
48
|
-
}, y = (e, t) => {
|
|
49
|
-
if (e.visible === t) return;
|
|
50
|
-
e.visible = t;
|
|
51
|
-
const { inner: o, options: i } = e;
|
|
52
|
-
p.killTweensOf(o), t ? p.to(o, {
|
|
53
|
-
y: 0,
|
|
54
|
-
opacity: 1,
|
|
55
|
-
scale: 1,
|
|
56
|
-
duration: 0.4,
|
|
57
|
-
ease: "back.out(1.7)",
|
|
58
|
-
overwrite: !0,
|
|
59
|
-
onStart: () => {
|
|
60
|
-
o.style.display = "flex";
|
|
61
|
-
}
|
|
62
|
-
}) : p.to(o, {
|
|
63
|
-
y: i.animationOffset,
|
|
64
|
-
opacity: 0,
|
|
65
|
-
scale: 0.8,
|
|
66
|
-
duration: 0.3,
|
|
67
|
-
ease: "power2.in",
|
|
68
|
-
overwrite: !0,
|
|
69
|
-
onComplete: () => {
|
|
70
|
-
o.style.display = "none";
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}, d = /* @__PURE__ */ new WeakMap(), R = {
|
|
44
|
+
u(g, "v-back-top-styles");
|
|
45
|
+
const b = (e) => {
|
|
46
|
+
const { wrapper: o, inner: t, options: r } = e;
|
|
47
|
+
o.style.zIndex = `${r.zIndex}`, t.style.setProperty("--vbt-size", `${r.size}px`), t.style.right = `${r.right}px`, t.style.bottom = `${r.bottom}px`, t.className = `v-back-top-inner bg-${r.type}`;
|
|
48
|
+
}, c = /* @__PURE__ */ new WeakMap(), P = {
|
|
74
49
|
name: "back-top",
|
|
75
|
-
mounted(e,
|
|
76
|
-
const
|
|
77
|
-
let
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
const
|
|
86
|
-
wrapper:
|
|
87
|
-
inner:
|
|
88
|
-
|
|
89
|
-
options: i,
|
|
50
|
+
mounted(e, o) {
|
|
51
|
+
const t = { ...m, ...o.value };
|
|
52
|
+
let r = "";
|
|
53
|
+
getComputedStyle(e).position === "static" && (r = e.style.position, e.style.position = "relative");
|
|
54
|
+
const a = document.createElement("div");
|
|
55
|
+
a.className = "v-back-top-wrapper";
|
|
56
|
+
const i = document.createElement("div");
|
|
57
|
+
i.title = "Back to top", v(h(y, { icon: w }), i), i.addEventListener("click", (n) => {
|
|
58
|
+
n.stopPropagation(), e.scrollTo({ top: 0, behavior: "smooth" });
|
|
59
|
+
}), a.appendChild(i), e.appendChild(a);
|
|
60
|
+
const s = {
|
|
61
|
+
wrapper: a,
|
|
62
|
+
inner: i,
|
|
63
|
+
options: t,
|
|
90
64
|
visible: !1,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
originalPosition:
|
|
95
|
-
handlers: {}
|
|
65
|
+
handler: () => {
|
|
66
|
+
},
|
|
67
|
+
observer: null,
|
|
68
|
+
originalPosition: r
|
|
96
69
|
};
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
70
|
+
b(s);
|
|
71
|
+
const p = f(() => {
|
|
72
|
+
const n = e.scrollTop > s.options.scrollThreshold;
|
|
73
|
+
s.visible !== n && (s.visible = n, l.killTweensOf(i), n ? l.to(i, {
|
|
74
|
+
y: 0,
|
|
75
|
+
opacity: 1,
|
|
76
|
+
scale: 1,
|
|
77
|
+
duration: 0.4,
|
|
78
|
+
ease: "back.out(1.7)",
|
|
79
|
+
overwrite: !0,
|
|
80
|
+
onStart: () => {
|
|
81
|
+
i.style.display = "flex";
|
|
82
|
+
}
|
|
83
|
+
}) : l.to(i, {
|
|
84
|
+
y: t.animationOffset,
|
|
85
|
+
opacity: 0,
|
|
86
|
+
scale: 0.8,
|
|
87
|
+
duration: 0.3,
|
|
88
|
+
ease: "power2.in",
|
|
89
|
+
overwrite: !0,
|
|
90
|
+
onComplete: () => {
|
|
91
|
+
i.style.display = "none";
|
|
92
|
+
}
|
|
93
|
+
}));
|
|
94
|
+
}, 100);
|
|
95
|
+
e.addEventListener("scroll", p, { passive: !0 });
|
|
96
|
+
const d = new ResizeObserver(p);
|
|
97
|
+
d.observe(e), s.handler = p, s.observer = d, c.set(e, s), p();
|
|
110
98
|
},
|
|
111
|
-
updated(e,
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
r.style.setProperty("--size", `${c.size}px`), s.style.zIndex = `${c.zIndex}`, r.className = `v-back-top-inner bg-${c.type}`, l(o);
|
|
118
|
-
const a = e.scrollTop > c.scrollThreshold;
|
|
119
|
-
y(o, a);
|
|
99
|
+
updated(e, o) {
|
|
100
|
+
const t = c.get(e);
|
|
101
|
+
if (!t) return;
|
|
102
|
+
t.options = { ...m, ...o.value }, b(t);
|
|
103
|
+
const r = e.scrollTop > t.options.scrollThreshold;
|
|
104
|
+
t.visible !== r && t.handler();
|
|
120
105
|
},
|
|
121
106
|
unmounted(e) {
|
|
122
|
-
const
|
|
123
|
-
|
|
107
|
+
const o = c.get(e);
|
|
108
|
+
o && (e.removeEventListener("scroll", o.handler), o.observer.disconnect(), l.killTweensOf(o.inner), v(null, o.inner), o.wrapper.remove(), c.delete(e));
|
|
124
109
|
}
|
|
125
110
|
};
|
|
126
111
|
export {
|
|
127
|
-
|
|
112
|
+
P as default
|
|
128
113
|
};
|
|
@@ -29,3 +29,22 @@ type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
29
29
|
$slots: S;
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
+
ue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
33
|
+
$slots: {
|
|
34
|
+
default?(_: {
|
|
35
|
+
row: {
|
|
36
|
+
index: number;
|
|
37
|
+
key: string;
|
|
38
|
+
data: any;
|
|
39
|
+
};
|
|
40
|
+
}): any;
|
|
41
|
+
empty?(_: {
|
|
42
|
+
row: {
|
|
43
|
+
index: number;
|
|
44
|
+
key: string;
|
|
45
|
+
data: any;
|
|
46
|
+
};
|
|
47
|
+
}): any;
|
|
48
|
+
};
|
|
49
|
+
})>;
|
|
50
|
+
export default _default;
|