@nutui/nutui 3.1.12-beta.1 → 3.1.14

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +139 -37
  3. package/dist/nutui.d.ts +9 -2
  4. package/dist/nutui.es.js +4830 -2950
  5. package/dist/nutui.umd.js +4910 -2953
  6. package/dist/packages/_es/ActionSheet.js +12 -13
  7. package/dist/packages/_es/Address.js +64 -77
  8. package/dist/packages/_es/Avatar.js +5 -4
  9. package/dist/packages/_es/BackTop.js +109 -72
  10. package/dist/packages/_es/Badge.js +5 -4
  11. package/dist/packages/_es/Barrage.js +57 -63
  12. package/dist/packages/_es/Button.js +6 -5
  13. package/dist/packages/_es/Calendar.js +18 -27
  14. package/dist/packages/_es/Card.js +8 -7
  15. package/dist/packages/_es/Cascader.js +547 -0
  16. package/dist/packages/_es/Cell.js +13 -5
  17. package/dist/packages/_es/CellGroup.js +14 -7
  18. package/dist/packages/_es/Checkbox.js +3 -3
  19. package/dist/packages/_es/CheckboxGroup.js +4 -9
  20. package/dist/packages/_es/CircleProgress.js +46 -142
  21. package/dist/packages/_es/Col.js +5 -4
  22. package/dist/packages/_es/Collapse.js +10 -35
  23. package/dist/packages/_es/CollapseItem.js +35 -80
  24. package/dist/packages/_es/CountDown.js +7 -10
  25. package/dist/packages/_es/CountUp.js +33 -34
  26. package/dist/packages/_es/DatePicker.js +219 -451
  27. package/dist/packages/_es/Dialog.js +98 -46
  28. package/dist/packages/_es/Divider.js +6 -5
  29. package/dist/packages/_es/Drag.js +50 -76
  30. package/dist/packages/_es/Elevator.js +53 -81
  31. package/dist/packages/_es/Empty.js +74 -0
  32. package/dist/packages/_es/FixedNav.js +9 -8
  33. package/dist/packages/_es/Form.js +23 -9
  34. package/dist/packages/_es/FormItem.js +5 -4
  35. package/dist/packages/_es/Grid.js +12 -0
  36. package/dist/packages/_es/GridItem.js +149 -0
  37. package/dist/packages/_es/Icon.js +40 -6
  38. package/dist/packages/_es/ImagePreview.js +158 -44
  39. package/dist/packages/_es/Indicator.js +66 -0
  40. package/dist/packages/_es/InfiniteLoading.js +109 -95
  41. package/dist/packages/_es/Input.js +21 -22
  42. package/dist/packages/_es/InputNumber.js +18 -24
  43. package/dist/packages/_es/Layout.js +2 -2
  44. package/dist/packages/_es/Menu.js +14 -16
  45. package/dist/packages/_es/MenuItem.js +11 -9
  46. package/dist/packages/_es/Navbar.js +7 -7
  47. package/dist/packages/_es/NoticeBar.js +31 -46
  48. package/dist/packages/_es/Notify.js +166 -30
  49. package/dist/packages/_es/NumberKeyboard.js +7 -9
  50. package/dist/packages/_es/OverLay.js +29 -22
  51. package/dist/packages/_es/Pagination.js +9 -8
  52. package/dist/packages/_es/Picker.js +447 -61
  53. package/dist/packages/_es/Popover.js +34 -161
  54. package/dist/packages/_es/Popup.js +77 -17
  55. package/dist/packages/_es/Price.js +7 -18
  56. package/dist/packages/_es/Progress.js +12 -23
  57. package/dist/packages/_es/Radio.js +3 -3
  58. package/dist/packages/_es/RadioGroup.js +2 -2
  59. package/dist/packages/_es/Range.js +31 -38
  60. package/dist/packages/_es/Rate.js +35 -17
  61. package/dist/packages/_es/Row.js +5 -4
  62. package/dist/packages/_es/SearchBar.js +5 -7
  63. package/dist/packages/_es/ShortPassword.js +59 -89
  64. package/dist/packages/_es/Signature.js +71 -70
  65. package/dist/packages/_es/Skeleton.js +138 -0
  66. package/dist/packages/_es/Sku.js +43 -53
  67. package/dist/packages/_es/Step.js +8 -10
  68. package/dist/packages/_es/Steps.js +2 -2
  69. package/dist/packages/_es/Swipe.js +28 -43
  70. package/dist/packages/_es/Swiper.js +418 -17
  71. package/dist/packages/_es/SwiperItem.js +39 -14
  72. package/dist/packages/_es/Switch.js +47 -16
  73. package/dist/packages/_es/TabPane.js +5 -4
  74. package/dist/packages/_es/Tabbar.js +5 -4
  75. package/dist/packages/_es/TabbarItem.js +9 -8
  76. package/dist/packages/_es/Table.js +191 -0
  77. package/dist/packages/_es/Tabs.js +21 -23
  78. package/dist/packages/_es/Tag.js +6 -5
  79. package/dist/packages/_es/TextArea.js +12 -16
  80. package/dist/packages/_es/TimeDetail.js +5 -7
  81. package/dist/packages/_es/TimePannel.js +5 -7
  82. package/dist/packages/_es/TimeSelect.js +7 -12
  83. package/dist/packages/_es/Toast.js +178 -46
  84. package/dist/packages/_es/Uploader.js +149 -109
  85. package/dist/packages/_es/Video.js +405 -0
  86. package/dist/packages/_es/common.js +136 -0
  87. package/dist/packages/_es/component.js +1 -1
  88. package/dist/packages/_es/index.js +7 -58
  89. package/dist/packages/_es/index2.js +58 -43
  90. package/dist/packages/_es/index3.js +28 -411
  91. package/dist/packages/_es/plugin-vue_export-helper.js +13 -0
  92. package/dist/packages/_es/pxCheck.js +1 -1
  93. package/dist/packages/_es/raf.js +1 -1
  94. package/dist/packages/_es/util.js +1 -1
  95. package/dist/packages/cascader/index.scss +81 -0
  96. package/dist/packages/cellgroup/index.scss +9 -0
  97. package/dist/packages/dialog/index.scss +17 -0
  98. package/dist/packages/drag/index.scss +4 -0
  99. package/dist/packages/empty/index.scss +33 -0
  100. package/dist/packages/fixednav/index.scss +6 -1
  101. package/dist/packages/formitem/index.scss +4 -1
  102. package/dist/packages/grid/index.scss +10 -0
  103. package/dist/packages/griditem/index.scss +92 -0
  104. package/dist/packages/icon/index.scss +2 -1
  105. package/dist/packages/indicator/index.scss +48 -0
  106. package/dist/packages/numberkeyboard/index.scss +1 -1
  107. package/dist/packages/popover/index.scss +2 -2
  108. package/dist/packages/rate/index.scss +1 -0
  109. package/dist/packages/skeleton/index.scss +57 -0
  110. package/dist/packages/table/index.scss +81 -0
  111. package/dist/packages/tabs/index.scss +16 -0
  112. package/dist/packages/textarea/index.scss +1 -0
  113. package/dist/packages/timedetail/index.scss +1 -2
  114. package/dist/packages/timeselect/index.scss +3 -0
  115. package/dist/packages/toast/index.scss +6 -0
  116. package/dist/style.css +1 -1
  117. package/dist/style.es.js +2 -1
  118. package/dist/styles/font/config.json +2 -1
  119. package/dist/styles/font/demo_index.html +26 -3
  120. package/dist/styles/font/iconfont.css +7 -3
  121. package/dist/styles/font/iconfont.js +31 -32
  122. package/dist/styles/font/iconfont.json +7 -0
  123. package/dist/styles/font/iconfont.ttf +0 -0
  124. package/dist/styles/font/iconfont.woff +0 -0
  125. package/dist/styles/font/iconfont.woff2 +0 -0
  126. package/dist/styles/themes/default.scss +40 -33
  127. package/dist/styles/variables.scss +54 -1
  128. package/package.json +2 -3
  129. package/dist/packages/_es/commonProps.js +0 -30
  130. package/dist/packages/_es/index.taro.vue_vue&type=script&lang.js +0 -44
  131. package/dist/packages/_es/use-lock-scroll.js +0 -23
@@ -17,28 +17,29 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __require = typeof require !== "undefined" ? require : (x) => {
21
- throw new Error('Dynamic require of "' + x + '" is not supported');
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
22
23
  };
23
24
  /*!
24
- * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
25
+ * @nutui/nutui v3.1.14 Wed Dec 22 2021 20:49:10 GMT+0800 (中国标准时间)
25
26
  * (c) 2021 @jdf2e.
26
27
  * Released under the MIT License.
27
28
  */
28
- import { ref, onMounted, watch, computed, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, normalizeClass, createElementBlock, renderSlot, Fragment, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle } from "vue";
29
+ import { ref, onMounted, watch, computed, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, normalizeClass, createElementBlock, renderSlot, Fragment, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle, createVNode, render, h } from "vue";
29
30
  import { c as createComponent } from "./component.js";
30
- import _sfc_main$1, { popupProps } from "./Popup.js";
31
- import _sfc_main$2 from "./Button.js";
32
- import "./use-lock-scroll.js";
31
+ import Popup, { popupProps } from "./Popup.js";
32
+ import Button from "./Button.js";
33
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
33
34
  import "./OverLay.js";
34
- import "./index.taro.vue_vue&type=script&lang.js";
35
+ import "./Icon.js";
35
36
  import "./pxCheck.js";
36
37
  const { componentName, create } = createComponent("dialog");
37
- var _sfc_main = create({
38
+ const _sfc_main = create({
38
39
  inheritAttrs: false,
39
40
  components: {
40
- [_sfc_main$1.name]: _sfc_main$1,
41
- [_sfc_main$2.name]: _sfc_main$2
41
+ [Popup.name]: Popup,
42
+ [Button.name]: Button
42
43
  },
43
44
  props: __spreadProps(__spreadValues({}, popupProps), {
44
45
  closeOnClickOverlay: {
@@ -85,37 +86,16 @@ var _sfc_main = create({
85
86
  type: String,
86
87
  default: "center"
87
88
  },
88
- onOk: {
89
- type: Function,
90
- default: null
91
- },
92
- onCancel: {
93
- type: Function,
94
- default: null
95
- },
96
- onClose: {
97
- type: Function,
98
- default: null
99
- },
100
- onClosed: {
101
- type: Function,
102
- default: null
103
- },
104
89
  closeOnPopstate: {
105
90
  type: Boolean,
106
91
  default: false
92
+ },
93
+ footerDirection: {
94
+ type: String,
95
+ default: "horizontal"
107
96
  }
108
97
  }),
109
- emits: [
110
- "update",
111
- "update:visible",
112
- "ok",
113
- "cancel",
114
- "open",
115
- "opened",
116
- "close",
117
- "closed"
118
- ],
98
+ emits: ["update", "update:visible", "ok", "cancel", "open", "opened", "close", "closed"],
119
99
  setup(props, { emit }) {
120
100
  const showPopup = ref(props.visible);
121
101
  onMounted(() => {
@@ -148,8 +128,8 @@ var _sfc_main = create({
148
128
  }
149
129
  };
150
130
  const onOk = () => {
151
- closed();
152
131
  emit("ok");
132
+ closed();
153
133
  };
154
134
  return {
155
135
  closed,
@@ -165,10 +145,6 @@ const _hoisted_1 = {
165
145
  class: "nut-dialog__header"
166
146
  };
167
147
  const _hoisted_2 = ["innerHTML"];
168
- const _hoisted_3 = {
169
- key: 1,
170
- class: "nut-dialog__footer"
171
- };
172
148
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
173
149
  const _component_nut_button = resolveComponent("nut-button");
174
150
  const _component_nut_popup = resolveComponent("nut-popup");
@@ -200,7 +176,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
200
176
  innerHTML: _ctx.content
201
177
  }, null, 8, _hoisted_2))
202
178
  ], 4),
203
- !_ctx.noFooter ? (openBlock(), createElementBlock("view", _hoisted_3, [
179
+ !_ctx.noFooter ? (openBlock(), createElementBlock("view", {
180
+ key: 1,
181
+ class: normalizeClass(["nut-dialog__footer", { [_ctx.footerDirection]: _ctx.footerDirection }])
182
+ }, [
204
183
  _ctx.$slots.footer ? renderSlot(_ctx.$slots, "footer", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
205
184
  !_ctx.noCancelBtn ? (openBlock(), createBlock(_component_nut_button, {
206
185
  key: 0,
@@ -229,11 +208,84 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
229
208
  _: 1
230
209
  }, 8, ["class", "disabled", "onClick"])) : createCommentVNode("", true)
231
210
  ], 64))
232
- ])) : createCommentVNode("", true)
211
+ ], 2)) : createCommentVNode("", true)
233
212
  ], 2)
234
213
  ]),
235
214
  _: 3
236
215
  }, 8, ["teleport", "visible", "close-on-click-overlay", "lock-scroll", "onClickOverlay", "onClickCloseIcon"]);
237
216
  }
238
- _sfc_main.render = _sfc_render;
239
- export { _sfc_main as default };
217
+ var Dialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
218
+ class DialogOptions {
219
+ constructor() {
220
+ __publicField(this, "title", "");
221
+ __publicField(this, "content", "");
222
+ __publicField(this, "cancelText", "\u53D6\u6D88");
223
+ __publicField(this, "okText", "\u786E\u5B9A");
224
+ __publicField(this, "textAlign", "center");
225
+ __publicField(this, "teleport", "body");
226
+ __publicField(this, "onUpdate", (value) => {
227
+ });
228
+ __publicField(this, "onOk", () => {
229
+ });
230
+ __publicField(this, "onCancel", () => {
231
+ });
232
+ __publicField(this, "onClose", () => {
233
+ });
234
+ __publicField(this, "onClosed", () => {
235
+ });
236
+ __publicField(this, "visible", true);
237
+ __publicField(this, "noFooter", false);
238
+ __publicField(this, "noOkBtn", false);
239
+ __publicField(this, "noCancelBtn", false);
240
+ __publicField(this, "okBtnDisabled", false);
241
+ __publicField(this, "closeOnPopstate", false);
242
+ __publicField(this, "lockScroll", false);
243
+ }
244
+ }
245
+ class DialogFunction {
246
+ constructor(_options) {
247
+ __publicField(this, "options", new DialogOptions());
248
+ __publicField(this, "close", () => {
249
+ });
250
+ __publicField(this, "setDefaultOptions", (options) => {
251
+ });
252
+ __publicField(this, "resetDefaultOptions", () => {
253
+ });
254
+ let options = Object.assign(this.options, _options);
255
+ let elWarp = document.body;
256
+ let teleport = options.teleport;
257
+ if (teleport != "body") {
258
+ if (typeof teleport == "string") {
259
+ elWarp = document.querySelector(teleport);
260
+ } else {
261
+ elWarp = options.teleport;
262
+ }
263
+ }
264
+ const root = document.createElement("view");
265
+ root.id = "dialog-" + new Date().getTime();
266
+ const Wrapper = {
267
+ setup() {
268
+ options.onUpdate = (val) => {
269
+ if (val == false) {
270
+ elWarp.removeChild(root);
271
+ }
272
+ };
273
+ options.teleport = `#${root.id}`;
274
+ return () => {
275
+ return h(Dialog, options);
276
+ };
277
+ }
278
+ };
279
+ const instance = createVNode(Wrapper);
280
+ elWarp.appendChild(root);
281
+ render(instance, root);
282
+ }
283
+ }
284
+ const _Dialog = function(options) {
285
+ return new DialogFunction(options);
286
+ };
287
+ _Dialog.install = (app) => {
288
+ app.use(Dialog);
289
+ app.config.globalProperties.$dialog = _Dialog;
290
+ };
291
+ export { Dialog, DialogOptions, _Dialog as default };
@@ -1,12 +1,13 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.14 Wed Dec 22 2021 20:49:10 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import { computed, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
8
9
  const { componentName, create } = createComponent("divider");
9
- var _sfc_main = create({
10
+ const _sfc_main = create({
10
11
  props: {
11
12
  contentPosition: {
12
13
  type: String,
@@ -38,11 +39,11 @@ var _sfc_main = create({
38
39
  }
39
40
  });
40
41
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
41
- return openBlock(), createElementBlock("view", {
42
+ return openBlock(), createElementBlock("div", {
42
43
  class: normalizeClass(_ctx.classes)
43
44
  }, [
44
45
  renderSlot(_ctx.$slots, "default")
45
46
  ], 2);
46
47
  }
47
- _sfc_main.render = _sfc_render;
48
- export { _sfc_main as default };
48
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
49
+ export { index as default };
@@ -1,14 +1,14 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.14 Wed Dec 22 2021 20:49:10 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref, reactive, computed, onMounted, onActivated, onDeactivated, openBlock, createElementBlock, normalizeClass, withModifiers, normalizeStyle, renderSlot } from "vue";
6
+ import { ref, reactive, computed, onMounted, onActivated, onDeactivated, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
7
7
  import { c as createComponent } from "./component.js";
8
8
  import { r as requestAniFrame } from "./raf.js";
9
- import Taro, { eventCenter, getCurrentInstance } from "@tarojs/taro";
9
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
10
10
  const { componentName, create } = createComponent("drag");
11
- var _sfc_main = create({
11
+ const _sfc_main = create({
12
12
  props: {
13
13
  attract: {
14
14
  type: Boolean,
@@ -40,13 +40,10 @@ var _sfc_main = create({
40
40
  screenHeight: 0,
41
41
  startTop: 0,
42
42
  startLeft: 0,
43
- initTop: 0,
44
43
  nx: 0,
45
44
  ny: 0,
46
45
  xPum: 0,
47
46
  yPum: 0,
48
- top: 0,
49
- left: 0,
50
47
  position: { x: 0, y: 0 },
51
48
  boundary: {
52
49
  top: 0,
@@ -56,58 +53,54 @@ var _sfc_main = create({
56
53
  }
57
54
  });
58
55
  const classes = computed(() => {
59
- const prefixCls = "nut-taro-drag";
56
+ const prefixCls = componentName;
60
57
  return {
61
58
  [prefixCls]: true
62
59
  };
63
60
  });
64
- const domElem = Taro.getSystemInfoSync();
65
61
  function getInfo() {
66
- const query = Taro.createSelectorQuery();
67
- query.select(".myDrag").boundingClientRect((rec) => {
68
- state.elWidth = rec.width;
69
- state.elHeight = rec.height;
70
- state.initTop = rec.top;
71
- }).exec();
72
- console.log(domElem.windowWidth);
73
- state.screenWidth = domElem.screenWidth;
74
- state.screenHeight = domElem.screenHeight;
62
+ const domElem = document.documentElement;
63
+ state.elWidth = myDrag.value.offsetWidth;
64
+ state.elHeight = myDrag.value.offsetHeight;
65
+ state.screenWidth = domElem.clientWidth;
66
+ state.screenHeight = domElem.clientHeight;
75
67
  }
76
- function goLeft() {
68
+ function goLeft(target) {
77
69
  if (state.boundary.left) {
78
- if (+state.left.split("px")[0] > state.boundary.left) {
79
- state.left = +state.left.split("px")[0] - 10 + "px";
70
+ if (+target.style.left.split("px")[0] > state.boundary.left) {
71
+ target.style.left = +target.style.left.split("px")[0] - 10 + "px";
80
72
  requestAniFrame(() => {
81
- goLeft();
73
+ goLeft(target);
82
74
  });
83
75
  } else {
84
- state.left = `${state.boundary.left}px`;
76
+ target.style.left = `${state.boundary.left}px`;
85
77
  }
86
78
  } else {
87
- if (+state.left.split("px")[0] > 10) {
88
- state.left = +state.left.split("px")[0] - 10 + "px";
79
+ if (+target.style.left.split("px")[0] > 10) {
80
+ target.style.left = +target.style.left.split("px")[0] - 10 + "px";
89
81
  requestAniFrame(() => {
90
- goLeft();
82
+ goLeft(target);
91
83
  });
92
84
  } else {
93
- state.left = "0px";
85
+ target.style.left = "0px";
94
86
  }
95
87
  }
96
88
  }
97
- function goRight(rightLocation) {
98
- if (rightLocation - parseInt(state.left.split("px")[0]) > 10) {
99
- state.left = parseInt(state.left.split("px")[0]) + 10 + "px";
89
+ function goRight(target, rightLocation) {
90
+ if (rightLocation - parseInt(target.style.left.split("px")[0]) > 10) {
91
+ target.style.left = parseInt(target.style.left.split("px")[0]) + 10 + "px";
100
92
  requestAniFrame(() => {
101
- goRight(rightLocation);
93
+ goRight(target, rightLocation);
102
94
  });
103
95
  } else {
104
- state.left = rightLocation + "px";
96
+ target.style.left = rightLocation + "px";
105
97
  }
106
98
  }
107
99
  function touchMove(e) {
108
100
  e.preventDefault();
109
- if (e.touches.length === 1) {
110
- const touch = e.touches[0];
101
+ const target = e.currentTarget;
102
+ if (e.targetTouches.length === 1) {
103
+ const touch = e.targetTouches[0];
111
104
  state.nx = touch.clientX - state.position.x;
112
105
  state.ny = touch.clientY - state.position.y;
113
106
  state.xPum = state.startLeft + state.nx;
@@ -124,14 +117,15 @@ var _sfc_main = create({
124
117
  state.yPum = state.screenHeight - state.elHeight - state.boundary.bottom;
125
118
  }
126
119
  if (props.direction != "y") {
127
- state.left = state.xPum;
120
+ target.style.left = state.xPum + "px";
128
121
  }
129
122
  if (props.direction != "x") {
130
- state.top = state.yPum;
123
+ target.style.top = state.yPum + "px";
131
124
  }
132
125
  }
133
126
  }
134
127
  function touchEnd(e) {
128
+ const target = e.currentTarget;
135
129
  const touch = e.changedTouches[0];
136
130
  let currX = touch.clientX;
137
131
  const rightLocation = state.screenWidth - state.elWidth - state.boundary.right;
@@ -145,47 +139,33 @@ var _sfc_main = create({
145
139
  if (props.direction != "y" && props.attract) {
146
140
  if (currX < state.screenWidth / 2) {
147
141
  requestAniFrame(() => {
148
- goLeft();
142
+ goLeft(target);
149
143
  });
150
144
  } else {
151
145
  requestAniFrame(() => {
152
- goRight(rightLocation);
146
+ goRight(target, rightLocation);
153
147
  });
154
148
  }
155
149
  }
156
- if (props.direction !== "x") {
157
- state.top = state.yPum;
150
+ if (props.direction != "x") {
151
+ target.style.top = state.yPum + "px";
158
152
  }
159
153
  }
160
154
  function touchStart(e) {
161
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
162
- const query = Taro.createSelectorQuery();
163
- let id = (_a = e == null ? void 0 : e.mpEvent) == null ? void 0 : _a.currentTarget.id;
164
- let offsetTop = (_b = e == null ? void 0 : e.currentTarget) == null ? void 0 : _b.offsetTop;
165
- let offsetLeft = (_c = e == null ? void 0 : e.currentTarget) == null ? void 0 : _c.offsetLeft;
155
+ const target = e.currentTarget;
166
156
  const touches = e.touches[0];
167
- const mobileTop = (_f = (_e = (_d = e.touches[0]) == null ? void 0 : _d.target) == null ? void 0 : _e.parentNode) == null ? void 0 : _f.style.top;
168
- const mobileLeft = (_i = (_h = (_g = e.touches[0]) == null ? void 0 : _g.target) == null ? void 0 : _h.parentNode) == null ? void 0 : _i.style.left;
169
- query.selectAll(".myDrag").boundingClientRect((rec) => {
170
- rec.forEach((element) => {
171
- if (id && id == element.id) {
172
- state.startTop = element.top - offsetTop;
173
- state.startLeft = element.left - offsetLeft;
174
- } else if (mobileTop) {
175
- state.startTop = Number(mobileTop.slice(0, -2));
176
- state.startLeft = Number(mobileLeft.slice(0, -2));
177
- }
178
- });
179
- }).exec();
157
+ const touch = e.targetTouches[0];
158
+ state.startTop = target.offsetTop;
159
+ state.startLeft = target.offsetLeft;
180
160
  state.position.x = touches.clientX;
181
161
  state.position.y = touches.clientY;
162
+ state.nx = touch.clientX - state.position.x;
163
+ state.ny = touch.clientY - state.position.y;
164
+ state.xPum = state.startLeft + state.nx;
165
+ state.yPum = state.startTop + state.ny;
182
166
  }
183
167
  onMounted(() => {
184
- setTimeout(() => {
185
- getInfo();
186
- }, 200);
187
- eventCenter.once(getCurrentInstance().router.onReady, () => {
188
- });
168
+ getInfo();
189
169
  state.boundary = props.boundary;
190
170
  });
191
171
  onActivated(() => {
@@ -204,26 +184,20 @@ var _sfc_main = create({
204
184
  myDrag,
205
185
  touchStart,
206
186
  touchMove,
207
- touchEnd,
208
- state
187
+ touchEnd
209
188
  };
210
189
  }
211
190
  });
212
191
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
213
192
  return openBlock(), createElementBlock("view", {
214
- class: normalizeClass([_ctx.classes, "myDrag"]),
193
+ class: normalizeClass(_ctx.classes),
215
194
  ref: "myDrag",
216
195
  onTouchstart: _cache[0] || (_cache[0] = ($event) => _ctx.touchStart($event)),
217
- onTouchmove: _cache[1] || (_cache[1] = withModifiers(($event) => _ctx.touchMove($event), ["prevent"])),
218
- catchtouchmove: "true",
219
- style: normalizeStyle({
220
- transform: ` translate(${_ctx.state.left + "px"}, ${_ctx.state.top + "px"})`,
221
- top: _ctx.state.top + "px",
222
- left: _ctx.state.left + "px"
223
- })
196
+ onTouchmove: _cache[1] || (_cache[1] = ($event) => _ctx.touchMove($event)),
197
+ onTouchend: _cache[2] || (_cache[2] = ($event) => _ctx.touchEnd($event))
224
198
  }, [
225
199
  renderSlot(_ctx.$slots, "default")
226
- ], 38);
200
+ ], 34);
227
201
  }
228
- _sfc_main.render = _sfc_render;
229
- export { _sfc_main as default };
202
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
203
+ export { index as default };