vant 2.12.37 → 2.12.38

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/index.js CHANGED
@@ -87,7 +87,7 @@ import Tag from './tag';
87
87
  import Toast from './toast';
88
88
  import TreeSelect from './tree-select';
89
89
  import Uploader from './uploader';
90
- var version = '2.12.37';
90
+ var version = '2.12.38';
91
91
 
92
92
  function install(Vue) {
93
93
  var components = [ActionSheet, AddressEdit, AddressList, Area, Badge, Button, Calendar, Card, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Circle, Col, Collapse, CollapseItem, ContactCard, ContactEdit, ContactList, CountDown, Coupon, CouponCell, CouponList, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, GoodsAction, GoodsActionButton, GoodsActionIcon, Grid, GridItem, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, List, Loading, Locale, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Panel, PasswordInput, Picker, Popover, Popup, Progress, PullRefresh, Radio, RadioGroup, Rate, Row, Search, ShareSheet, Sidebar, SidebarItem, Skeleton, Sku, Slider, Step, Stepper, Steps, Sticky, SubmitBar, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, TreeSelect, Uploader];
@@ -1,12 +1,11 @@
1
1
  import { on } from '../utils/dom/event';
2
- var MIN_DISTANCE = 10;
3
2
 
4
3
  function getDirection(x, y) {
5
- if (x > y && x > MIN_DISTANCE) {
4
+ if (x > y) {
6
5
  return 'horizontal';
7
6
  }
8
7
 
9
- if (y > x && y > MIN_DISTANCE) {
8
+ if (y > x) {
10
9
  return 'vertical';
11
10
  }
12
11
 
@@ -26,13 +25,18 @@ export var TouchMixin = {
26
25
  this.startY = event.touches[0].clientY;
27
26
  },
28
27
  touchMove: function touchMove(event) {
29
- var touch = event.touches[0]; // Fix: Safari back will set clientX to negative number
28
+ var touch = event.touches[0]; // safari back will set clientX to negative number
30
29
 
31
30
  this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
32
31
  this.deltaY = touch.clientY - this.startY;
33
32
  this.offsetX = Math.abs(this.deltaX);
34
- this.offsetY = Math.abs(this.deltaY);
35
- this.direction = this.direction || getDirection(this.offsetX, this.offsetY);
33
+ this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
34
+
35
+ var LOCK_DIRECTION_DISTANCE = 10;
36
+
37
+ if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
38
+ this.direction = getDirection(this.offsetX, this.offsetY);
39
+ }
36
40
  },
37
41
  resetTouchStatus: function resetTouchStatus() {
38
42
  this.direction = '';
@@ -233,6 +233,7 @@ export default createComponent({
233
233
  var renderButton = function renderButton(i) {
234
234
  var map = ['left', 'right'];
235
235
  var isNumber = typeof i === 'number';
236
+ var current = isNumber ? _this.value[i] : _this.value;
236
237
 
237
238
  var getClassName = function getClassName() {
238
239
  if (isNumber) {
@@ -250,6 +251,27 @@ export default createComponent({
250
251
  return "wrapper";
251
252
  };
252
253
 
254
+ var renderButtonContent = function renderButtonContent() {
255
+ if (isNumber) {
256
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
257
+ value: current
258
+ });
259
+
260
+ if (slot) {
261
+ return slot;
262
+ }
263
+ }
264
+
265
+ if (_this.slots('button')) {
266
+ return _this.slots('button');
267
+ }
268
+
269
+ return h("div", {
270
+ "class": bem('button'),
271
+ "style": _this.buttonStyle
272
+ });
273
+ };
274
+
253
275
  return h("div", {
254
276
  "ref": getRefName(),
255
277
  "attrs": {
@@ -272,10 +294,7 @@ export default createComponent({
272
294
  return e.stopPropagation();
273
295
  }
274
296
  }
275
- }, [_this.slots('button') || h("div", {
276
- "class": bem('button'),
277
- "style": _this.buttonStyle
278
- })]);
297
+ }, [renderButtonContent()]);
279
298
  };
280
299
 
281
300
  return h("div", {
package/es/swipe/index.js CHANGED
@@ -181,16 +181,10 @@ export default createComponent({
181
181
  },
182
182
  onTouchMove: function onTouchMove(event) {
183
183
  if (!this.touchable || !this.swiping) return;
184
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
185
- // avoid affecting the parent components
186
-
187
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
188
-
189
- if (shouldPrevent) {
190
- preventDefault(event, this.stopPropagation);
191
- }
184
+ this.touchMove(event);
192
185
 
193
186
  if (this.isCorrectDirection) {
187
+ preventDefault(event, this.stopPropagation);
194
188
  this.move({
195
189
  offset: this.delta
196
190
  });
package/lib/index.js CHANGED
@@ -361,7 +361,7 @@ exports.TreeSelect = _treeSelect.default;
361
361
  var _uploader = _interopRequireDefault(require("./uploader"));
362
362
 
363
363
  exports.Uploader = _uploader.default;
364
- var version = '2.12.37';
364
+ var version = '2.12.38';
365
365
  exports.version = version;
366
366
 
367
367
  function install(Vue) {
@@ -5,14 +5,12 @@ exports.TouchMixin = void 0;
5
5
 
6
6
  var _event = require("../utils/dom/event");
7
7
 
8
- var MIN_DISTANCE = 10;
9
-
10
8
  function getDirection(x, y) {
11
- if (x > y && x > MIN_DISTANCE) {
9
+ if (x > y) {
12
10
  return 'horizontal';
13
11
  }
14
12
 
15
- if (y > x && y > MIN_DISTANCE) {
13
+ if (y > x) {
16
14
  return 'vertical';
17
15
  }
18
16
 
@@ -32,13 +30,18 @@ var TouchMixin = {
32
30
  this.startY = event.touches[0].clientY;
33
31
  },
34
32
  touchMove: function touchMove(event) {
35
- var touch = event.touches[0]; // Fix: Safari back will set clientX to negative number
33
+ var touch = event.touches[0]; // safari back will set clientX to negative number
36
34
 
37
35
  this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
38
36
  this.deltaY = touch.clientY - this.startY;
39
37
  this.offsetX = Math.abs(this.deltaX);
40
- this.offsetY = Math.abs(this.deltaY);
41
- this.direction = this.direction || getDirection(this.offsetX, this.offsetY);
38
+ this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
39
+
40
+ var LOCK_DIRECTION_DISTANCE = 10;
41
+
42
+ if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
43
+ this.direction = getDirection(this.offsetX, this.offsetY);
44
+ }
42
45
  },
43
46
  resetTouchStatus: function resetTouchStatus() {
44
47
  this.direction = '';
@@ -243,6 +243,7 @@ var _default = createComponent({
243
243
  var renderButton = function renderButton(i) {
244
244
  var map = ['left', 'right'];
245
245
  var isNumber = typeof i === 'number';
246
+ var current = isNumber ? _this.value[i] : _this.value;
246
247
 
247
248
  var getClassName = function getClassName() {
248
249
  if (isNumber) {
@@ -260,6 +261,27 @@ var _default = createComponent({
260
261
  return "wrapper";
261
262
  };
262
263
 
264
+ var renderButtonContent = function renderButtonContent() {
265
+ if (isNumber) {
266
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
267
+ value: current
268
+ });
269
+
270
+ if (slot) {
271
+ return slot;
272
+ }
273
+ }
274
+
275
+ if (_this.slots('button')) {
276
+ return _this.slots('button');
277
+ }
278
+
279
+ return h("div", {
280
+ "class": bem('button'),
281
+ "style": _this.buttonStyle
282
+ });
283
+ };
284
+
263
285
  return h("div", {
264
286
  "ref": getRefName(),
265
287
  "attrs": {
@@ -282,10 +304,7 @@ var _default = createComponent({
282
304
  return e.stopPropagation();
283
305
  }
284
306
  }
285
- }, [_this.slots('button') || h("div", {
286
- "class": bem('button'),
287
- "style": _this.buttonStyle
288
- })]);
307
+ }, [renderButtonContent()]);
289
308
  };
290
309
 
291
310
  return h("div", {
@@ -193,16 +193,10 @@ var _default = createComponent({
193
193
  },
194
194
  onTouchMove: function onTouchMove(event) {
195
195
  if (!this.touchable || !this.swiping) return;
196
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
197
- // avoid affecting the parent components
198
-
199
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
200
-
201
- if (shouldPrevent) {
202
- (0, _event.preventDefault)(event, this.stopPropagation);
203
- }
196
+ this.touchMove(event);
204
197
 
205
198
  if (this.isCorrectDirection) {
199
+ (0, _event.preventDefault)(event, this.stopPropagation);
206
200
  this.move({
207
201
  offset: this.delta
208
202
  });
package/lib/vant.js CHANGED
@@ -1194,14 +1194,13 @@ function getVisibleTop(el) {
1194
1194
  }
1195
1195
  // CONCATENATED MODULE: ./es/mixins/touch.js
1196
1196
 
1197
- var MIN_DISTANCE = 10;
1198
1197
 
1199
1198
  function getDirection(x, y) {
1200
- if (x > y && x > MIN_DISTANCE) {
1199
+ if (x > y) {
1201
1200
  return 'horizontal';
1202
1201
  }
1203
1202
 
1204
- if (y > x && y > MIN_DISTANCE) {
1203
+ if (y > x) {
1205
1204
  return 'vertical';
1206
1205
  }
1207
1206
 
@@ -1221,13 +1220,18 @@ var TouchMixin = {
1221
1220
  this.startY = event.touches[0].clientY;
1222
1221
  },
1223
1222
  touchMove: function touchMove(event) {
1224
- var touch = event.touches[0]; // Fix: Safari back will set clientX to negative number
1223
+ var touch = event.touches[0]; // safari back will set clientX to negative number
1225
1224
 
1226
1225
  this.deltaX = touch.clientX < 0 ? 0 : touch.clientX - this.startX;
1227
1226
  this.deltaY = touch.clientY - this.startY;
1228
1227
  this.offsetX = Math.abs(this.deltaX);
1229
- this.offsetY = Math.abs(this.deltaY);
1230
- this.direction = this.direction || getDirection(this.offsetX, this.offsetY);
1228
+ this.offsetY = Math.abs(this.deltaY); // lock direction when distance is greater than a certain value
1229
+
1230
+ var LOCK_DIRECTION_DISTANCE = 10;
1231
+
1232
+ if (!this.direction || this.offsetX < LOCK_DIRECTION_DISTANCE && this.offsetY < LOCK_DIRECTION_DISTANCE) {
1233
+ this.direction = getDirection(this.offsetX, this.offsetY);
1234
+ }
1231
1235
  },
1232
1236
  resetTouchStatus: function resetTouchStatus() {
1233
1237
  this.direction = '';
@@ -12816,16 +12820,10 @@ var swipe_createNamespace = Object(create["a" /* createNamespace */])('swipe'),
12816
12820
  },
12817
12821
  onTouchMove: function onTouchMove(event) {
12818
12822
  if (!this.touchable || !this.swiping) return;
12819
- this.touchMove(event); // if user starting to touchmove, prevent the event bubbling to
12820
- // avoid affecting the parent components
12821
-
12822
- var shouldPrevent = this.isCorrectDirection || this.offsetY > this.offsetX === this.vertical;
12823
-
12824
- if (shouldPrevent) {
12825
- preventDefault(event, this.stopPropagation);
12826
- }
12823
+ this.touchMove(event);
12827
12824
 
12828
12825
  if (this.isCorrectDirection) {
12826
+ preventDefault(event, this.stopPropagation);
12829
12827
  this.move({
12830
12828
  offset: this.delta
12831
12829
  });
@@ -21109,6 +21107,7 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21109
21107
  var renderButton = function renderButton(i) {
21110
21108
  var map = ['left', 'right'];
21111
21109
  var isNumber = typeof i === 'number';
21110
+ var current = isNumber ? _this.value[i] : _this.value;
21112
21111
 
21113
21112
  var getClassName = function getClassName() {
21114
21113
  if (isNumber) {
@@ -21126,6 +21125,27 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21126
21125
  return "wrapper";
21127
21126
  };
21128
21127
 
21128
+ var renderButtonContent = function renderButtonContent() {
21129
+ if (isNumber) {
21130
+ var slot = _this.slots(i === 0 ? 'left-button' : 'right-button', {
21131
+ value: current
21132
+ });
21133
+
21134
+ if (slot) {
21135
+ return slot;
21136
+ }
21137
+ }
21138
+
21139
+ if (_this.slots('button')) {
21140
+ return _this.slots('button');
21141
+ }
21142
+
21143
+ return h("div", {
21144
+ "class": slider_bem('button'),
21145
+ "style": _this.buttonStyle
21146
+ });
21147
+ };
21148
+
21129
21149
  return h("div", {
21130
21150
  "ref": getRefName(),
21131
21151
  "attrs": {
@@ -21148,10 +21168,7 @@ var isSameValue = function isSameValue(newValue, oldValue) {
21148
21168
  return e.stopPropagation();
21149
21169
  }
21150
21170
  }
21151
- }, [_this.slots('button') || h("div", {
21152
- "class": slider_bem('button'),
21153
- "style": _this.buttonStyle
21154
- })]);
21171
+ }, [renderButtonContent()]);
21155
21172
  };
21156
21173
 
21157
21174
  return h("div", {
@@ -22173,7 +22190,7 @@ TreeSelect.props = {
22173
22190
 
22174
22191
 
22175
22192
 
22176
- var version = '2.12.37';
22193
+ var version = '2.12.38';
22177
22194
 
22178
22195
  function install(Vue) {
22179
22196
  var components = [action_sheet, address_edit, address_list, es_area, badge, es_button, calendar, card, cascader, cell, cell_group, es_checkbox, checkbox_group, circle, col, collapse, collapse_item, contact_card, contact_edit, contact_list, count_down, es_coupon, coupon_cell, coupon_list, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, es_form, goods_action, goods_action_button, goods_action_icon, grid, grid_item, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, es_list, es_loading, locale["a" /* default */], nav_bar, notice_bar, notify, number_keyboard, es_overlay, pagination, panel, password_input, es_picker, popover, popup, es_progress, pull_refresh, es_radio, radio_group, es_rate, row, search, share_sheet, sidebar, sidebar_item, skeleton, es_sku, slider, es_step, stepper, steps, es_sticky, submit_bar, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, tabs, es_tag, es_toast, tree_select, uploader];