@varlet/ui 2.6.2 → 2.6.3

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/swipe/Swipe.js CHANGED
@@ -103,17 +103,17 @@ export default defineComponent({
103
103
  var dispatchBorrower = () => {
104
104
  if (!props.loop) {
105
105
  return;
106
- } // track越左边界
106
+ } // track out of bounds from left
107
107
 
108
108
 
109
109
  if (translate.value >= 0) {
110
110
  findSwipeItem(length.value - 1).setTranslate(-trackSize.value);
111
- } // track越右边界
111
+ } // track out of bounds from right
112
112
 
113
113
 
114
114
  if (translate.value <= -(trackSize.value - size.value)) {
115
115
  findSwipeItem(0).setTranslate(trackSize.value);
116
- } // track没越界
116
+ } // track not out of bounds
117
117
 
118
118
 
119
119
  if (translate.value > -(trackSize.value - size.value) && translate.value < 0) {
@@ -300,6 +300,10 @@ export default defineComponent({
300
300
 
301
301
 
302
302
  var resize = () => {
303
+ if (!swipeEl.value) {
304
+ return;
305
+ }
306
+
303
307
  lockDuration.value = true;
304
308
  size.value = props.vertical ? swipeEl.value.offsetHeight : swipeEl.value.offsetWidth;
305
309
  trackSize.value = size.value * length.value;
@@ -314,7 +318,7 @@ export default defineComponent({
314
318
  }; // expose
315
319
 
316
320
 
317
- var next = () => {
321
+ var next = options => {
318
322
  if (length.value <= 1) {
319
323
  return;
320
324
  }
@@ -325,7 +329,11 @@ export default defineComponent({
325
329
  } = props;
326
330
  var currentIndex = index.value;
327
331
  index.value = boundaryIndex(currentIndex + 1);
328
- call(onChange, index.value);
332
+
333
+ if ((options == null ? void 0 : options.event) !== false) {
334
+ call(onChange, index.value);
335
+ }
336
+
329
337
  fixPosition(() => {
330
338
  if (currentIndex === length.value - 1 && loop) {
331
339
  findSwipeItem(0).setTranslate(trackSize.value);
@@ -340,7 +348,7 @@ export default defineComponent({
340
348
  }; // expose
341
349
 
342
350
 
343
- var prev = () => {
351
+ var prev = options => {
344
352
  if (length.value <= 1) {
345
353
  return;
346
354
  }
@@ -351,7 +359,11 @@ export default defineComponent({
351
359
  } = props;
352
360
  var currentIndex = index.value;
353
361
  index.value = boundaryIndex(currentIndex - 1);
354
- call(onChange, index.value);
362
+
363
+ if ((options == null ? void 0 : options.event) !== false) {
364
+ call(onChange, index.value);
365
+ }
366
+
355
367
  fixPosition(() => {
356
368
  if (currentIndex === 0 && loop) {
357
369
  findSwipeItem(length.value - 1).setTranslate(-trackSize.value);
@@ -366,7 +378,7 @@ export default defineComponent({
366
378
  }; // expose
367
379
 
368
380
 
369
- var to = idx => {
381
+ var to = (idx, options) => {
370
382
  if (length.value <= 1 || idx === index.value) {
371
383
  return;
372
384
  }
@@ -374,9 +386,14 @@ export default defineComponent({
374
386
  idx = idx < 0 ? 0 : idx;
375
387
  idx = idx >= length.value ? length.value : idx;
376
388
  var task = idx > index.value ? next : prev;
389
+ var count = Math.abs(idx - index.value);
377
390
  Array.from({
378
- length: Math.abs(idx - index.value)
379
- }).forEach(task);
391
+ length: count
392
+ }).forEach((_, index) => {
393
+ task({
394
+ event: index === count - 1 ? options == null ? void 0 : options.event : false
395
+ });
396
+ });
380
397
  };
381
398
 
382
399
  var swipeProvider = {