@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.
@@ -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 formatTime = durationTime => {
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.value) {
99
- endTime.value = now + toNumber(time);
97
+ if (!endTime) {
98
+ endTime = now + toNumber(time);
100
99
  }
101
100
 
102
- var durationTime = endTime.value - now;
101
+ remainingTime = endTime - now;
103
102
 
104
- if (durationTime < 0) {
105
- durationTime = 0;
103
+ if (remainingTime < 0) {
104
+ remainingTime = 0;
106
105
  }
107
106
 
108
- pauseTime.value = durationTime;
109
- formatTime(durationTime);
107
+ displayTime(remainingTime);
110
108
 
111
- if (durationTime === 0) {
109
+ if (remainingTime === 0) {
112
110
  call(onEnd);
113
111
  return;
114
112
  }
115
113
 
116
- if (autoStart || isStart.value) {
117
- handle.value = requestAnimationFrame(countdown);
114
+ if (isStart) {
115
+ handle = requestAnimationFrame(countdown);
118
116
  }
119
117
  }; // expose
120
118
 
121
119
 
122
- var start = () => {
123
- if (isStart.value) {
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.value = true;
128
- endTime.value = performance.now() + (pauseTime.value || toNumber(props.time));
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.value = false;
135
- cancelAnimationFrame(handle.value);
136
+ isStart = false;
137
+ cancelAnimationFrame(handle);
136
138
  }; // expose
137
139
 
138
140
 
139
141
  var reset = () => {
140
- endTime.value = 0;
141
- isStart.value = false;
142
- cancelAnimationFrame(handle.value);
142
+ endTime = 0;
143
+ isStart = false;
144
+ cancelAnimationFrame(handle);
143
145
  countdown();
144
146
  };
145
147
 
146
- watch(() => props.time, reset, {
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.value = cacheIsStart;
162
+ isStart = cacheIsStart;
155
163
 
156
- if (isStart.value === true) {
157
- countdown();
164
+ if (isStart === true) {
165
+ start(true);
158
166
  }
159
167
  });
160
168
  onDeactivated(() => {
161
- cacheIsStart = isStart.value;
169
+ cacheIsStart = isStart;
162
170
  pause();
163
171
  });
164
172
  onUnmounted(pause);
@@ -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-alpha.1678026868230'
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-alpha.1678026868230'
159
+ const version = '2.8.6'
160
160
 
161
161
  function install(app) {
162
162
  ActionSheet.install && app.use(ActionSheet)