@varlet/ui 2.8.6-alpha.1678026101378 → 2.8.6-alpha.1678028497778

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,11 @@ 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
+ var cacheIsStart;
43
44
 
44
45
  var parseFormat = (format, time) => {
45
46
  var scannedTimes = Object.values(time);
@@ -94,59 +95,67 @@ var __sfc__ = defineComponent({
94
95
  } = props;
95
96
  var now = performance.now();
96
97
 
97
- if (!endTime.value) {
98
- endTime.value = now + toNumber(time);
98
+ if (!endTime) {
99
+ endTime = now + toNumber(time);
99
100
  }
100
101
 
101
- var durationTime = endTime.value - now;
102
+ remainingTime = endTime - now;
102
103
 
103
- if (durationTime < 0) {
104
- durationTime = 0;
104
+ if (remainingTime < 0) {
105
+ remainingTime = 0;
105
106
  }
106
107
 
107
- pauseTime.value = durationTime;
108
- formatTime(durationTime);
108
+ formatTime(remainingTime);
109
109
 
110
- if (durationTime === 0) {
110
+ if (remainingTime === 0) {
111
111
  call(onEnd);
112
112
  return;
113
113
  }
114
114
 
115
- if (autoStart || isStart.value) {
116
- handle.value = requestAnimationFrame(countdown);
115
+ if (autoStart || isStart) {
116
+ handle = requestAnimationFrame(countdown);
117
117
  }
118
118
  }; // expose
119
119
 
120
120
 
121
121
  var start = () => {
122
- if (isStart.value) {
123
- return;
124
- }
125
-
126
- isStart.value = true;
127
- endTime.value = performance.now() + (pauseTime.value || toNumber(props.time));
122
+ isStart = true;
123
+ endTime = performance.now() + (remainingTime || toNumber(props.time));
128
124
  countdown();
129
125
  }; // expose
130
126
 
131
127
 
132
128
  var pause = () => {
133
- isStart.value = false;
134
- cancelAnimationFrame(handle.value);
129
+ isStart = false;
130
+ cancelAnimationFrame(handle);
135
131
  }; // expose
136
132
 
137
133
 
138
134
  var reset = () => {
139
- endTime.value = 0;
140
- isStart.value = false;
141
- cancelAnimationFrame(handle.value);
135
+ endTime = 0;
136
+ isStart = false;
137
+ cancelAnimationFrame(handle);
142
138
  countdown();
143
139
  };
144
140
 
145
141
  watch(() => props.time, reset, {
146
142
  immediate: true
147
143
  });
148
- onActivated(start);
149
- onDeactivated(pause);
144
+ onActivated(() => {
145
+ if (cacheIsStart == null) {
146
+ return;
147
+ }
148
+
149
+ isStart = cacheIsStart;
150
+
151
+ if (isStart === true) {
152
+ start();
153
+ }
154
+ });
155
+ onDeactivated(() => {
156
+ cacheIsStart = isStart;
157
+ pause();
158
+ });
150
159
  onUnmounted(pause);
151
160
  return {
152
161
  showTime,
@@ -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.1678026101378'
238
+ const version = '2.8.6-alpha.1678028497778'
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.1678026101378'
159
+ const version = '2.8.6-alpha.1678028497778'
160
160
 
161
161
  function install(app) {
162
162
  ActionSheet.install && app.use(ActionSheet)