geekin-devtoys 0.0.2 → 0.0.4
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.
- package/lib/Demo/index.js +1 -1
- package/lib/Demo/index.mjs +10 -13
- package/lib/GCount/index.js +1 -0
- package/lib/{CountUp → GCount}/index.mjs +6 -5
- package/lib/GPercent/index.js +1 -0
- package/lib/GPercent/index.mjs +101 -0
- package/lib/GPercent/style.css +1 -0
- package/lib/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/lib/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +11 -9
- package/package.json +20 -12
- package/lib/CountUp/index.js +0 -1
- /package/lib/{index → Demo}/style.css +0 -0
package/lib/Demo/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),n=require("../_plugin-vue_export-helper-BHFhmbuH.js"),s={class:"demo"},r=Object.assign({name:"Demo"},{__name:"index",props:{msg:String},setup(t){return(c,a)=>(o.openBlock(),o.createElementBlock("div",s,o.toDisplayString(t.msg),1))}}),e=n._export_sfc(r,[["__scopeId","data-v-bd7af65f"]]);e.install=t=>{t.component(e.name,e)};exports.Demo=e;exports.default=e;
|
package/lib/Demo/index.mjs
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { createElementBlock as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (const [s, c] of n)
|
|
5
|
-
e[s] = c;
|
|
6
|
-
return e;
|
|
7
|
-
}, p = { class: "demo" }, i = /* @__PURE__ */ Object.assign({
|
|
1
|
+
import { createElementBlock as o, openBlock as s, toDisplayString as n } from "vue";
|
|
2
|
+
import { _ as a } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
3
|
+
const c = { class: "demo" }, m = /* @__PURE__ */ Object.assign({
|
|
8
4
|
name: "Demo"
|
|
9
5
|
}, {
|
|
10
6
|
__name: "index",
|
|
11
7
|
props: {
|
|
12
8
|
msg: String
|
|
13
9
|
},
|
|
14
|
-
setup(
|
|
15
|
-
return (
|
|
10
|
+
setup(e) {
|
|
11
|
+
return (r, _) => (s(), o("div", c, n(e.msg), 1));
|
|
16
12
|
}
|
|
17
|
-
}),
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
}), t = /* @__PURE__ */ a(m, [["__scopeId", "data-v-bd7af65f"]]);
|
|
14
|
+
t.install = (e) => {
|
|
15
|
+
e.component(t.name, t);
|
|
20
16
|
};
|
|
21
17
|
export {
|
|
22
|
-
|
|
18
|
+
t as Demo,
|
|
19
|
+
t as default
|
|
23
20
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),i=t.defineComponent({name:"GCount",__name:"index",props:{to:{},from:{default:0},direction:{default:"up"},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},separator:{default:""},onStart:{},onEnd:{}},setup(p){const e=p,o=t.useTemplateRef("elementRef"),r=t.ref(e.direction==="down"?e.to:e.from),c=t.ref(!1),n=t.ref(null),m=t.ref(!1);let s=null;const h=t.computed(()=>20+40*(1/e.duration)),F=t.computed(()=>100*(1/e.duration));let u=0;const _=a=>{const l={useGrouping:!!e.separator,minimumFractionDigits:0,maximumFractionDigits:0},f=Intl.NumberFormat("en-US",l).format(Number(a.toFixed(0)));return e.separator?f.replace(/,/g,e.separator):f},d=()=>{o.value&&(o.value.textContent=_(r.value))},v=a=>{const l=e.direction==="down"?e.from:e.to,f=r.value,b=l-f,S=b*F.value,I=u*h.value,M=S-I;u+=M*.016,r.value+=u*.016,d(),Math.abs(b)>.01||Math.abs(u)>.01?n.value=requestAnimationFrame(v):(r.value=l,d(),n.value=null,e.onEnd&&e.onEnd())},g=()=>{m.value||!c.value||!e.startWhen||(m.value=!0,e.onStart&&e.onStart(),setTimeout(()=>{u=0,n.value=requestAnimationFrame(v)},e.delay*1e3))},w=()=>{o.value&&(s=new IntersectionObserver(([a])=>{a.isIntersecting&&!c.value&&(c.value=!0,g())},{threshold:0,rootMargin:"0px"}),s.observe(o.value))},y=()=>{n.value&&(cancelAnimationFrame(n.value),n.value=null),s&&(s.disconnect(),s=null)};return t.watch([()=>e.from,()=>e.to,()=>e.direction],()=>{r.value=e.direction==="down"?e.to:e.from,d(),m.value=!1},{immediate:!0}),t.watch(()=>e.startWhen,()=>{e.startWhen&&c.value&&!m.value&&g()}),t.onMounted(()=>{d(),w()}),t.onUnmounted(()=>{y()}),(a,l)=>(t.openBlock(),t.createElementBlock("span",{ref_key:"elementRef",ref:o,class:t.normalizeClass(a.className)},null,2))}});i.install=p=>{p.component(i.name,i)};exports.GCount=i;exports.default=i;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as S, useTemplateRef as E, ref as f, computed as b, watch as F, onMounted as M, onUnmounted as R, createElementBlock as
|
|
1
|
+
import { defineComponent as S, useTemplateRef as E, ref as f, computed as b, watch as F, onMounted as M, onUnmounted as R, createElementBlock as W, openBlock as k, normalizeClass as B } from "vue";
|
|
2
2
|
const p = /* @__PURE__ */ S({
|
|
3
|
-
name: "
|
|
3
|
+
name: "GCount",
|
|
4
4
|
__name: "index",
|
|
5
5
|
props: {
|
|
6
6
|
to: {},
|
|
@@ -63,10 +63,10 @@ const p = /* @__PURE__ */ S({
|
|
|
63
63
|
c(), I();
|
|
64
64
|
}), R(() => {
|
|
65
65
|
N();
|
|
66
|
-
}), (n, l) => (
|
|
66
|
+
}), (n, l) => (k(), W("span", {
|
|
67
67
|
ref_key: "elementRef",
|
|
68
68
|
ref: a,
|
|
69
|
-
class:
|
|
69
|
+
class: B(n.className)
|
|
70
70
|
}, null, 2));
|
|
71
71
|
}
|
|
72
72
|
});
|
|
@@ -74,5 +74,6 @@ p.install = (d) => {
|
|
|
74
74
|
d.component(p.name, p);
|
|
75
75
|
};
|
|
76
76
|
export {
|
|
77
|
-
p as
|
|
77
|
+
p as GCount,
|
|
78
|
+
p as default
|
|
78
79
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),S=require("../_plugin-vue_export-helper-BHFhmbuH.js"),E="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-466%20)'%3e%3cpath%20d='M%201755.77886671114%20477.5%20L%201760.5%20467.199345551568%20L%201765.22113328886%20477.5%20L%201755.77886671114%20477.5%20Z%20'%20fill-rule='nonzero'%20fill='%23fa3239'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20478%20L%201760.5%20466%20L%201766%20478%20L%201755%20478%20Z%20M%201760.5%20468.398691103136%20L%201756.55773342227%20477%20L%201764.44226657773%20477%20L%201760.5%20468.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e",V="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-304%20)'%3e%3cpath%20d='M%201755.77886671114%20315.5%20L%201760.5%20305.199345551568%20L%201765.22113328886%20315.5%20L%201755.77886671114%20315.5%20Z%20'%20fill-rule='nonzero'%20fill='%232ce534'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20316%20L%201760.5%20304%20L%201766%20316%20L%201755%20316%20Z%20M%201760.5%20306.398691103136%20L%201756.55773342227%20315%20L%201764.44226657773%20315%20L%201760.5%20306.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e",N={class:"g-percent-symbol-updown"},P={src:E,alt:"down",style:{transform:"rotate(180deg)"},class:"g-percent-svg"},z={src:V,alt:"up",class:"g-percent-svg"},F=t.defineComponent({name:"GPercent",__name:"index",props:{to:{},from:{default:0},direction:{default:""},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},decimalPlaces:{default:0},onStart:{},onEnd:{}},setup(d){const e=d,m=t.useTemplateRef("elementRef"),n=t.ref(e.direction==="down"?e.to:e.from),c=t.ref(!1),o=t.ref(null),u=t.ref(!1);let r=null;const g=t.computed(()=>20+40*(1/e.duration)),w=t.computed(()=>200*(1/e.duration));let a=0;const p=l=>{const s=e.direction==="down"?e.from:e.to,_=n.value,f=s-_,L=f*w.value,b=a*g.value,M=L-b;a+=M*.016,n.value+=a*.016,n.value=Math.max(0,Math.min(100,n.value));const y=Math.pow(10,-e.decimalPlaces)*.1,k=Math.pow(10,-e.decimalPlaces)*.1;Math.abs(f)>y||Math.abs(a)>k?o.value=requestAnimationFrame(p):(n.value=s,o.value=null,e.onEnd&&e.onEnd())},v=()=>{u.value||!c.value||!e.startWhen||(u.value=!0,e.onStart&&e.onStart(),setTimeout(()=>{a=0,o.value=requestAnimationFrame(p)},e.delay*1e3))},h=()=>{m.value&&(r=new IntersectionObserver(([l])=>{l.isIntersecting&&!c.value&&(c.value=!0,v())},{threshold:0,rootMargin:"0px"}),r.observe(m.value))},x=()=>{o.value&&(cancelAnimationFrame(o.value),o.value=null),r&&(r.disconnect(),r=null)};return t.watch([()=>e.from,()=>e.to,()=>e.direction],()=>{n.value=e.direction==="down"?e.to:e.from,u.value=!1},{immediate:!0}),t.watch(()=>e.startWhen,()=>{e.startWhen&&c.value&&!u.value&&v()}),t.onMounted(async()=>{await t.nextTick(),h()}),t.onUnmounted(()=>{x()}),(l,s)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"elementRef",ref:m,class:t.normalizeClass([l.className,"g-percent-container"])},[t.createElementVNode("div",N,[t.withDirectives(t.createElementVNode("img",P,null,512),[[t.vShow,e.direction==="down"]]),t.withDirectives(t.createElementVNode("img",z,null,512),[[t.vShow,e.direction==="up"]])]),t.createElementVNode("span",{class:t.normalizeClass(["g-percent-number",{"g-percent-number-down":e.direction==="down","g-percent-number-up":e.direction==="up"}])},t.toDisplayString(n.value.toFixed(e.decimalPlaces)),3),t.createElementVNode("div",{class:t.normalizeClass(["g-percent-symbol",{"g-percent-number-down":e.direction==="down","g-percent-number-up":e.direction==="up"}])},[t.renderSlot(l.$slots,"symbol",{},()=>[s[0]||(s[0]=t.createTextVNode("%"))],!0)],2)],2))}}),i=S._export_sfc(F,[["__scopeId","data-v-33634690"]]);i.install=d=>{d.component(i.name,i)};exports.GPercent=i;exports.default=i;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { defineComponent as A, useTemplateRef as E, ref as u, computed as h, watch as x, onMounted as T, nextTick as N, onUnmounted as R, createElementBlock as V, openBlock as W, normalizeClass as p, createElementVNode as l, withDirectives as L, vShow as _, toDisplayString as B, renderSlot as O, createTextVNode as q } from "vue";
|
|
2
|
+
import { _ as C } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
3
|
+
const D = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-466%20)'%3e%3cpath%20d='M%201755.77886671114%20477.5%20L%201760.5%20467.199345551568%20L%201765.22113328886%20477.5%20L%201755.77886671114%20477.5%20Z%20'%20fill-rule='nonzero'%20fill='%23fa3239'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20478%20L%201760.5%20466%20L%201766%20478%20L%201755%20478%20Z%20M%201760.5%20468.398691103136%20L%201756.55773342227%20477%20L%201764.44226657773%20477%20L%201760.5%20468.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e", G = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20version='1.1'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='11px'%20height='12px'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20transform='matrix(1%200%200%201%20-1755%20-304%20)'%3e%3cpath%20d='M%201755.77886671114%20315.5%20L%201760.5%20305.199345551568%20L%201765.22113328886%20315.5%20L%201755.77886671114%20315.5%20Z%20'%20fill-rule='nonzero'%20fill='%232ce534'%20stroke='none'%20/%3e%3cpath%20d='M%201755%20316%20L%201760.5%20304%20L%201766%20316%20L%201755%20316%20Z%20M%201760.5%20306.398691103136%20L%201756.55773342227%20315%20L%201764.44226657773%20315%20L%201760.5%20306.398691103136%20Z%20'%20fill-rule='nonzero'%20fill='%23797979'%20stroke='none'%20/%3e%3c/g%3e%3c/svg%3e", U = { class: "g-percent-symbol-updown" }, $ = {
|
|
4
|
+
src: D,
|
|
5
|
+
alt: "down",
|
|
6
|
+
style: { transform: "rotate(180deg)" },
|
|
7
|
+
class: "g-percent-svg"
|
|
8
|
+
}, j = {
|
|
9
|
+
src: G,
|
|
10
|
+
alt: "up",
|
|
11
|
+
class: "g-percent-svg"
|
|
12
|
+
}, H = /* @__PURE__ */ A({
|
|
13
|
+
name: "GPercent",
|
|
14
|
+
__name: "index",
|
|
15
|
+
props: {
|
|
16
|
+
to: {},
|
|
17
|
+
from: { default: 0 },
|
|
18
|
+
direction: { default: "" },
|
|
19
|
+
delay: { default: 0 },
|
|
20
|
+
duration: { default: 2 },
|
|
21
|
+
className: { default: "" },
|
|
22
|
+
startWhen: { type: Boolean, default: !0 },
|
|
23
|
+
decimalPlaces: { default: 0 },
|
|
24
|
+
onStart: {},
|
|
25
|
+
onEnd: {}
|
|
26
|
+
},
|
|
27
|
+
setup(d) {
|
|
28
|
+
const e = d, m = E("elementRef"), t = u(e.direction === "down" ? e.to : e.from), i = u(!1), n = u(null), c = u(!1);
|
|
29
|
+
let o = null;
|
|
30
|
+
const b = h(() => 20 + 40 * (1 / e.duration)), M = h(() => 200 * (1 / e.duration));
|
|
31
|
+
let r = 0;
|
|
32
|
+
const v = (a) => {
|
|
33
|
+
const s = e.direction === "down" ? e.from : e.to, S = t.value, w = s - S, F = w * M.value, I = r * b.value, P = F - I;
|
|
34
|
+
r += P * 0.016, t.value += r * 0.016, t.value = Math.max(0, Math.min(100, t.value));
|
|
35
|
+
const Z = Math.pow(10, -e.decimalPlaces) * 0.1, z = Math.pow(10, -e.decimalPlaces) * 0.1;
|
|
36
|
+
Math.abs(w) > Z || Math.abs(r) > z ? n.value = requestAnimationFrame(v) : (t.value = s, n.value = null, e.onEnd && e.onEnd());
|
|
37
|
+
}, g = () => {
|
|
38
|
+
c.value || !i.value || !e.startWhen || (c.value = !0, e.onStart && e.onStart(), setTimeout(() => {
|
|
39
|
+
r = 0, n.value = requestAnimationFrame(v);
|
|
40
|
+
}, e.delay * 1e3));
|
|
41
|
+
}, k = () => {
|
|
42
|
+
m.value && (o = new IntersectionObserver(
|
|
43
|
+
([a]) => {
|
|
44
|
+
a.isIntersecting && !i.value && (i.value = !0, g());
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
threshold: 0,
|
|
48
|
+
rootMargin: "0px"
|
|
49
|
+
}
|
|
50
|
+
), o.observe(m.value));
|
|
51
|
+
}, y = () => {
|
|
52
|
+
n.value && (cancelAnimationFrame(n.value), n.value = null), o && (o.disconnect(), o = null);
|
|
53
|
+
};
|
|
54
|
+
return x(
|
|
55
|
+
[() => e.from, () => e.to, () => e.direction],
|
|
56
|
+
() => {
|
|
57
|
+
t.value = e.direction === "down" ? e.to : e.from, c.value = !1;
|
|
58
|
+
},
|
|
59
|
+
{ immediate: !0 }
|
|
60
|
+
), x(
|
|
61
|
+
() => e.startWhen,
|
|
62
|
+
() => {
|
|
63
|
+
e.startWhen && i.value && !c.value && g();
|
|
64
|
+
}
|
|
65
|
+
), T(async () => {
|
|
66
|
+
await N(), k();
|
|
67
|
+
}), R(() => {
|
|
68
|
+
y();
|
|
69
|
+
}), (a, s) => (W(), V("div", {
|
|
70
|
+
ref_key: "elementRef",
|
|
71
|
+
ref: m,
|
|
72
|
+
class: p([a.className, "g-percent-container"])
|
|
73
|
+
}, [
|
|
74
|
+
l("div", U, [
|
|
75
|
+
L(l("img", $, null, 512), [
|
|
76
|
+
[_, e.direction === "down"]
|
|
77
|
+
]),
|
|
78
|
+
L(l("img", j, null, 512), [
|
|
79
|
+
[_, e.direction === "up"]
|
|
80
|
+
])
|
|
81
|
+
]),
|
|
82
|
+
l("span", {
|
|
83
|
+
class: p(["g-percent-number", { "g-percent-number-down": e.direction === "down", "g-percent-number-up": e.direction === "up" }])
|
|
84
|
+
}, B(t.value.toFixed(e.decimalPlaces)), 3),
|
|
85
|
+
l("div", {
|
|
86
|
+
class: p(["g-percent-symbol", { "g-percent-number-down": e.direction === "down", "g-percent-number-up": e.direction === "up" }])
|
|
87
|
+
}, [
|
|
88
|
+
O(a.$slots, "symbol", {}, () => [
|
|
89
|
+
s[0] || (s[0] = q("%"))
|
|
90
|
+
], !0)
|
|
91
|
+
], 2)
|
|
92
|
+
], 2));
|
|
93
|
+
}
|
|
94
|
+
}), f = /* @__PURE__ */ C(H, [["__scopeId", "data-v-33634690"]]);
|
|
95
|
+
f.install = (d) => {
|
|
96
|
+
d.component(f.name, f);
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
f as GPercent,
|
|
100
|
+
f as default
|
|
101
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.g-percent-container[data-v-33634690]{display:inline-flex;align-items:center;justify-content:center}.g-percent-number-down[data-v-33634690]{color:#ff4d4f}.g-percent-number-up[data-v-33634690]{color:#52c41a}.g-percent-svg[data-v-33634690]{width:8px;height:8px}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=(t,o)=>{const c=t.__vccOpts||t;for(const[r,s]of o)c[r]=s;return c};exports._export_sfc=e;
|
package/lib/index/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../Demo/index.js"),n=require("../GCount/index.js"),u=require("../GPercent/index.js"),t={Demo:o.default,GCount:n.default,GPercent:u.default},l=c=>{Object.keys(t).forEach(r=>{const e=t[r];c.component(e.name,e)})},s={install:l};exports.Demo=o.default;exports.GCount=n.default;exports.GPercent=u.default;exports.default=s;
|
package/lib/index/index.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import m from "../Demo/index.mjs";
|
|
2
|
+
import c from "../GCount/index.mjs";
|
|
3
|
+
import s from "../GPercent/index.mjs";
|
|
4
|
+
const n = { Demo: m, GCount: c, GPercent: s }, r = (t) => {
|
|
5
|
+
Object.keys(n).forEach((e) => {
|
|
6
|
+
const o = n[e];
|
|
6
7
|
t.component(o.name, o);
|
|
7
8
|
});
|
|
8
|
-
},
|
|
9
|
+
}, i = { install: r };
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
-
c as
|
|
12
|
-
|
|
11
|
+
m as Demo,
|
|
12
|
+
c as GCount,
|
|
13
|
+
s as GPercent,
|
|
14
|
+
i as default
|
|
13
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geekin-devtoys",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"author": "leon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "geekin-devtoys组件库",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"lib": "vite build && node update-exports.js"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"vite-plugin-dts": "^4.5.4",
|
|
17
16
|
"@babel/core": "^7.12.16",
|
|
18
17
|
"core-js": "^3.8.3",
|
|
19
18
|
"file-loader": "^6.2.0",
|
|
20
19
|
"rollup-plugin-visualizer": "^6.0.1",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"tsx": "^4.19.1",
|
|
21
|
+
"vite-plugin-dts": "^4.5.4",
|
|
22
|
+
"vite-plugin-libcss": "^1.1.1"
|
|
23
23
|
},
|
|
24
24
|
"browserslist": [
|
|
25
25
|
"> 1%",
|
|
@@ -35,14 +35,6 @@
|
|
|
35
35
|
"import": "./lib/index/style.css",
|
|
36
36
|
"require": "./lib/index/style.css"
|
|
37
37
|
},
|
|
38
|
-
"./CountUp": {
|
|
39
|
-
"import": "./lib/CountUp/index.mjs",
|
|
40
|
-
"require": "./lib/CountUp/index.js"
|
|
41
|
-
},
|
|
42
|
-
"./CountUp/style": {
|
|
43
|
-
"import": "./lib/CountUp/style.css",
|
|
44
|
-
"require": "./lib/CountUp/style.css"
|
|
45
|
-
},
|
|
46
38
|
"./Demo": {
|
|
47
39
|
"import": "./lib/Demo/index.mjs",
|
|
48
40
|
"require": "./lib/Demo/index.js"
|
|
@@ -50,6 +42,22 @@
|
|
|
50
42
|
"./Demo/style": {
|
|
51
43
|
"import": "./lib/Demo/style.css",
|
|
52
44
|
"require": "./lib/Demo/style.css"
|
|
45
|
+
},
|
|
46
|
+
"./GCount": {
|
|
47
|
+
"import": "./lib/GCount/index.mjs",
|
|
48
|
+
"require": "./lib/GCount/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./GCount/style": {
|
|
51
|
+
"import": "./lib/GCount/style.css",
|
|
52
|
+
"require": "./lib/GCount/style.css"
|
|
53
|
+
},
|
|
54
|
+
"./GPercent": {
|
|
55
|
+
"import": "./lib/GPercent/index.mjs",
|
|
56
|
+
"require": "./lib/GPercent/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./GPercent/style": {
|
|
59
|
+
"import": "./lib/GPercent/style.css",
|
|
60
|
+
"require": "./lib/GPercent/style.css"
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
}
|
package/lib/CountUp/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),d=t.defineComponent({name:"GCountUp",__name:"index",props:{to:{},from:{default:0},direction:{default:"up"},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},separator:{default:""},onStart:{},onEnd:{}},setup(p){const e=p,o=t.useTemplateRef("elementRef"),r=t.ref(e.direction==="down"?e.to:e.from),i=t.ref(!1),n=t.ref(null),c=t.ref(!1);let s=null;const h=t.computed(()=>20+40*(1/e.duration)),F=t.computed(()=>100*(1/e.duration));let u=0;const y=a=>{const l={useGrouping:!!e.separator,minimumFractionDigits:0,maximumFractionDigits:0},f=Intl.NumberFormat("en-US",l).format(Number(a.toFixed(0)));return e.separator?f.replace(/,/g,e.separator):f},m=()=>{o.value&&(o.value.textContent=y(r.value))},v=a=>{const l=e.direction==="down"?e.from:e.to,f=r.value,b=l-f,I=b*F.value,N=u*h.value,_=I-N;u+=_*.016,r.value+=u*.016,m(),Math.abs(b)>.01||Math.abs(u)>.01?n.value=requestAnimationFrame(v):(r.value=l,m(),n.value=null,e.onEnd&&e.onEnd())},g=()=>{c.value||!i.value||!e.startWhen||(c.value=!0,e.onStart&&e.onStart(),setTimeout(()=>{u=0,n.value=requestAnimationFrame(v)},e.delay*1e3))},w=()=>{o.value&&(s=new IntersectionObserver(([a])=>{a.isIntersecting&&!i.value&&(i.value=!0,g())},{threshold:0,rootMargin:"0px"}),s.observe(o.value))},S=()=>{n.value&&(cancelAnimationFrame(n.value),n.value=null),s&&(s.disconnect(),s=null)};return t.watch([()=>e.from,()=>e.to,()=>e.direction],()=>{r.value=e.direction==="down"?e.to:e.from,m(),c.value=!1},{immediate:!0}),t.watch(()=>e.startWhen,()=>{e.startWhen&&i.value&&!c.value&&g()}),t.onMounted(()=>{m(),w()}),t.onUnmounted(()=>{S()}),(a,l)=>(t.openBlock(),t.createElementBlock("span",{ref_key:"elementRef",ref:o,class:t.normalizeClass(a.className)},null,2))}});d.install=p=>{p.component(d.name,d)};exports.CountUp=d;
|
|
File without changes
|