dpzvc3-ui 3.0.4 → 3.0.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dpzvc3-ui",
3
- "version": "3.0.4",
4
- "description": "Vue组件库",
3
+ "version": "3.0.6",
4
+ "description": "Vue3组件库",
5
5
  "main": "dist/dpzvc3.js",
6
6
  "module": "dist/dpzvc3.esm.js",
7
7
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  v-if="cancleText"
21
21
  href="javascript:;"
22
22
  :class="cancleClass"
23
- @click="visible = false"
23
+ @click="cancleClick"
24
24
  >{{ cancleText }}</a>
25
25
  </div>
26
26
  </Popup>
@@ -80,6 +80,9 @@ export default defineComponent({
80
80
  emit('update:modelValue', false)
81
81
  }
82
82
 
83
+ const cancleClick = () => {
84
+ emit('update:modelValue', false)
85
+ }
83
86
  return {
84
87
  visible,
85
88
  actions,
@@ -87,6 +90,7 @@ export default defineComponent({
87
90
  wrapperClasses,
88
91
  wrapperActionClass,
89
92
  cancleClass,
93
+ cancleClick,
90
94
  emit: emitAction
91
95
  }
92
96
  }
@@ -61,7 +61,7 @@
61
61
 
62
62
  <script>
63
63
  import { defineComponent, ref, computed, onMounted, onBeforeUnmount } from 'vue'
64
-
64
+ import rafTimeout from '../../lib/lib'
65
65
  const prefixCls = 'dpzvc3-swipe'
66
66
 
67
67
  export default defineComponent({
@@ -205,7 +205,7 @@ export default defineComponent({
205
205
  }
206
206
 
207
207
  function autoSlide () {
208
- timer.value = setTimeout(() => {
208
+ timer.value = rafTimeout(() => {
209
209
  if (!dragging.value && autoSwipe.value) {
210
210
  translateX.value -= clientWidth.value
211
211
  console.log(slideIndex.value, maxIndex.value, 'dsdadddasdss')
@@ -233,7 +233,8 @@ export default defineComponent({
233
233
  }
234
234
 
235
235
  function clearTimer () {
236
- if (timer.value) clearTimeout(timer.value)
236
+ // if (timer.value) clearTimeout(timer.value)
237
+ timer.value && timer.value()
237
238
  timer.value = null
238
239
  }
239
240
 
package/src/lib/lib.js ADDED
@@ -0,0 +1,22 @@
1
+ const rafTimeout = (callback, delay) => {
2
+ let start = null
3
+ let rafId
4
+
5
+ function loop (timestamp) {
6
+ if (!start) start = timestamp
7
+
8
+ if (timestamp - start >= delay) {
9
+ callback()
10
+ cancelAnimationFrame(rafId)
11
+ } else {
12
+ rafId = requestAnimationFrame(loop)
13
+ }
14
+ }
15
+
16
+ rafId = requestAnimationFrame(loop)
17
+
18
+ // 返回清除方法
19
+ return () => cancelAnimationFrame(rafId)
20
+ }
21
+
22
+ export default rafTimeout