@varlet/ui 2.8.6-alpha.1678026868230 → 2.8.6
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/es/countdown/Countdown.mjs +39 -31
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/varlet.esm.js +680 -681
- package/highlight/web-types.en-US.json +1 -1
- package/highlight/web-types.zh-CN.json +1 -1
- package/lib/varlet.cjs.js +38 -32
- package/package.json +6 -6
- package/umd/varlet.js +5 -5
|
@@ -28,11 +28,7 @@ var __sfc__ = defineComponent({
|
|
|
28
28
|
props,
|
|
29
29
|
|
|
30
30
|
setup(props) {
|
|
31
|
-
var endTime = ref(0);
|
|
32
|
-
var isStart = ref(false);
|
|
33
31
|
var showTime = ref('');
|
|
34
|
-
var handle = ref(0);
|
|
35
|
-
var pauseTime = ref(0);
|
|
36
32
|
var timeData = ref({
|
|
37
33
|
days: 0,
|
|
38
34
|
hours: 0,
|
|
@@ -40,6 +36,10 @@ var __sfc__ = defineComponent({
|
|
|
40
36
|
seconds: 0,
|
|
41
37
|
milliseconds: 0
|
|
42
38
|
});
|
|
39
|
+
var endTime = 0;
|
|
40
|
+
var isStart = false;
|
|
41
|
+
var handle = 0;
|
|
42
|
+
var remainingTime = 0;
|
|
43
43
|
var cacheIsStart;
|
|
44
44
|
|
|
45
45
|
var parseFormat = (format, time) => {
|
|
@@ -69,7 +69,7 @@ var __sfc__ = defineComponent({
|
|
|
69
69
|
return format;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
var
|
|
72
|
+
var displayTime = durationTime => {
|
|
73
73
|
var days = Math.floor(durationTime / DAY);
|
|
74
74
|
var hours = Math.floor(durationTime % DAY / HOUR);
|
|
75
75
|
var minutes = Math.floor(durationTime % HOUR / MINUTE);
|
|
@@ -90,60 +90,68 @@ var __sfc__ = defineComponent({
|
|
|
90
90
|
var countdown = () => {
|
|
91
91
|
var {
|
|
92
92
|
time,
|
|
93
|
-
onEnd
|
|
94
|
-
autoStart
|
|
93
|
+
onEnd
|
|
95
94
|
} = props;
|
|
96
95
|
var now = performance.now();
|
|
97
96
|
|
|
98
|
-
if (!endTime
|
|
99
|
-
endTime
|
|
97
|
+
if (!endTime) {
|
|
98
|
+
endTime = now + toNumber(time);
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
|
|
101
|
+
remainingTime = endTime - now;
|
|
103
102
|
|
|
104
|
-
if (
|
|
105
|
-
|
|
103
|
+
if (remainingTime < 0) {
|
|
104
|
+
remainingTime = 0;
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
|
|
109
|
-
formatTime(durationTime);
|
|
107
|
+
displayTime(remainingTime);
|
|
110
108
|
|
|
111
|
-
if (
|
|
109
|
+
if (remainingTime === 0) {
|
|
112
110
|
call(onEnd);
|
|
113
111
|
return;
|
|
114
112
|
}
|
|
115
113
|
|
|
116
|
-
if (
|
|
117
|
-
handle
|
|
114
|
+
if (isStart) {
|
|
115
|
+
handle = requestAnimationFrame(countdown);
|
|
118
116
|
}
|
|
119
117
|
}; // expose
|
|
120
118
|
|
|
121
119
|
|
|
122
|
-
var start = ()
|
|
123
|
-
if (
|
|
120
|
+
var start = function (resume) {
|
|
121
|
+
if (resume === void 0) {
|
|
122
|
+
resume = false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (isStart && !resume) {
|
|
124
126
|
return;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
isStart
|
|
128
|
-
endTime
|
|
129
|
+
isStart = true;
|
|
130
|
+
endTime = performance.now() + (remainingTime || toNumber(props.time));
|
|
129
131
|
countdown();
|
|
130
132
|
}; // expose
|
|
131
133
|
|
|
132
134
|
|
|
133
135
|
var pause = () => {
|
|
134
|
-
isStart
|
|
135
|
-
cancelAnimationFrame(handle
|
|
136
|
+
isStart = false;
|
|
137
|
+
cancelAnimationFrame(handle);
|
|
136
138
|
}; // expose
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
var reset = () => {
|
|
140
|
-
endTime
|
|
141
|
-
isStart
|
|
142
|
-
cancelAnimationFrame(handle
|
|
142
|
+
endTime = 0;
|
|
143
|
+
isStart = false;
|
|
144
|
+
cancelAnimationFrame(handle);
|
|
143
145
|
countdown();
|
|
144
146
|
};
|
|
145
147
|
|
|
146
|
-
watch(() => props.time,
|
|
148
|
+
watch(() => props.time, () => {
|
|
149
|
+
reset();
|
|
150
|
+
|
|
151
|
+
if (props.autoStart) {
|
|
152
|
+
start();
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
147
155
|
immediate: true
|
|
148
156
|
});
|
|
149
157
|
onActivated(() => {
|
|
@@ -151,14 +159,14 @@ var __sfc__ = defineComponent({
|
|
|
151
159
|
return;
|
|
152
160
|
}
|
|
153
161
|
|
|
154
|
-
isStart
|
|
162
|
+
isStart = cacheIsStart;
|
|
155
163
|
|
|
156
|
-
if (isStart
|
|
157
|
-
|
|
164
|
+
if (isStart === true) {
|
|
165
|
+
start(true);
|
|
158
166
|
}
|
|
159
167
|
});
|
|
160
168
|
onDeactivated(() => {
|
|
161
|
-
cacheIsStart = isStart
|
|
169
|
+
cacheIsStart = isStart;
|
|
162
170
|
pause();
|
|
163
171
|
});
|
|
164
172
|
onUnmounted(pause);
|
package/es/index.bundle.mjs
CHANGED
|
@@ -235,7 +235,7 @@ import './time-picker/style/index.mjs'
|
|
|
235
235
|
import './tooltip/style/index.mjs'
|
|
236
236
|
import './uploader/style/index.mjs'
|
|
237
237
|
|
|
238
|
-
const version = '2.8.6
|
|
238
|
+
const version = '2.8.6'
|
|
239
239
|
|
|
240
240
|
function install(app) {
|
|
241
241
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -156,7 +156,7 @@ export * from './time-picker/index.mjs'
|
|
|
156
156
|
export * from './tooltip/index.mjs'
|
|
157
157
|
export * from './uploader/index.mjs'
|
|
158
158
|
|
|
159
|
-
const version = '2.8.6
|
|
159
|
+
const version = '2.8.6'
|
|
160
160
|
|
|
161
161
|
function install(app) {
|
|
162
162
|
ActionSheet.install && app.use(ActionSheet)
|