@nutui/nutui 3.1.12-beta.1 → 3.1.12

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 (114) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/nutui.d.ts +1 -1
  3. package/dist/nutui.es.js +3219 -2562
  4. package/dist/nutui.umd.js +3292 -2565
  5. package/dist/packages/_es/ActionSheet.js +12 -13
  6. package/dist/packages/_es/Address.js +49 -63
  7. package/dist/packages/_es/Avatar.js +5 -4
  8. package/dist/packages/_es/BackTop.js +109 -72
  9. package/dist/packages/_es/Badge.js +5 -4
  10. package/dist/packages/_es/Barrage.js +57 -63
  11. package/dist/packages/_es/Button.js +6 -5
  12. package/dist/packages/_es/Calendar.js +18 -27
  13. package/dist/packages/_es/Card.js +8 -7
  14. package/dist/packages/_es/Cell.js +13 -5
  15. package/dist/packages/_es/CellGroup.js +14 -7
  16. package/dist/packages/_es/Checkbox.js +3 -3
  17. package/dist/packages/_es/CheckboxGroup.js +4 -9
  18. package/dist/packages/_es/CircleProgress.js +46 -142
  19. package/dist/packages/_es/Col.js +5 -4
  20. package/dist/packages/_es/Collapse.js +10 -35
  21. package/dist/packages/_es/CollapseItem.js +35 -80
  22. package/dist/packages/_es/CountDown.js +5 -7
  23. package/dist/packages/_es/CountUp.js +31 -34
  24. package/dist/packages/_es/DatePicker.js +219 -451
  25. package/dist/packages/_es/Dialog.js +98 -46
  26. package/dist/packages/_es/Divider.js +6 -5
  27. package/dist/packages/_es/Drag.js +50 -76
  28. package/dist/packages/_es/Elevator.js +52 -81
  29. package/dist/packages/_es/FixedNav.js +9 -8
  30. package/dist/packages/_es/Form.js +6 -5
  31. package/dist/packages/_es/FormItem.js +5 -4
  32. package/dist/packages/_es/Icon.js +40 -6
  33. package/dist/packages/_es/ImagePreview.js +158 -44
  34. package/dist/packages/_es/InfiniteLoading.js +109 -95
  35. package/dist/packages/_es/Input.js +21 -22
  36. package/dist/packages/_es/InputNumber.js +18 -24
  37. package/dist/packages/_es/Layout.js +2 -2
  38. package/dist/packages/_es/Menu.js +14 -16
  39. package/dist/packages/_es/MenuItem.js +11 -9
  40. package/dist/packages/_es/Navbar.js +7 -7
  41. package/dist/packages/_es/NoticeBar.js +26 -39
  42. package/dist/packages/_es/Notify.js +166 -30
  43. package/dist/packages/_es/NumberKeyboard.js +7 -9
  44. package/dist/packages/_es/OverLay.js +29 -22
  45. package/dist/packages/_es/Pagination.js +9 -8
  46. package/dist/packages/_es/Picker.js +447 -61
  47. package/dist/packages/_es/Popover.js +34 -161
  48. package/dist/packages/_es/Popup.js +77 -17
  49. package/dist/packages/_es/Price.js +7 -18
  50. package/dist/packages/_es/Progress.js +12 -23
  51. package/dist/packages/_es/Radio.js +3 -3
  52. package/dist/packages/_es/RadioGroup.js +2 -2
  53. package/dist/packages/_es/Range.js +31 -38
  54. package/dist/packages/_es/Rate.js +35 -17
  55. package/dist/packages/_es/Row.js +5 -4
  56. package/dist/packages/_es/SearchBar.js +5 -7
  57. package/dist/packages/_es/ShortPassword.js +59 -89
  58. package/dist/packages/_es/Signature.js +71 -70
  59. package/dist/packages/_es/Sku.js +43 -53
  60. package/dist/packages/_es/Step.js +8 -10
  61. package/dist/packages/_es/Steps.js +2 -2
  62. package/dist/packages/_es/Swipe.js +28 -43
  63. package/dist/packages/_es/Swiper.js +418 -17
  64. package/dist/packages/_es/SwiperItem.js +39 -14
  65. package/dist/packages/_es/Switch.js +32 -11
  66. package/dist/packages/_es/TabPane.js +5 -4
  67. package/dist/packages/_es/Tabbar.js +5 -4
  68. package/dist/packages/_es/TabbarItem.js +9 -8
  69. package/dist/packages/_es/Tabs.js +16 -22
  70. package/dist/packages/_es/Tag.js +6 -5
  71. package/dist/packages/_es/TextArea.js +12 -16
  72. package/dist/packages/_es/TimeDetail.js +5 -7
  73. package/dist/packages/_es/TimePannel.js +5 -7
  74. package/dist/packages/_es/TimeSelect.js +7 -12
  75. package/dist/packages/_es/Toast.js +178 -46
  76. package/dist/packages/_es/Uploader.js +149 -109
  77. package/dist/packages/_es/Video.js +405 -0
  78. package/dist/packages/_es/component.js +1 -1
  79. package/dist/packages/_es/index.js +7 -58
  80. package/dist/packages/_es/index2.js +58 -43
  81. package/dist/packages/_es/index3.js +28 -411
  82. package/dist/packages/_es/plugin-vue_export-helper.js +13 -0
  83. package/dist/packages/_es/pxCheck.js +1 -1
  84. package/dist/packages/_es/raf.js +1 -1
  85. package/dist/packages/_es/util.js +1 -1
  86. package/dist/packages/cellgroup/index.scss +9 -0
  87. package/dist/packages/dialog/index.scss +17 -0
  88. package/dist/packages/drag/index.scss +4 -0
  89. package/dist/packages/fixednav/index.scss +6 -1
  90. package/dist/packages/formitem/index.scss +3 -0
  91. package/dist/packages/icon/index.scss +2 -1
  92. package/dist/packages/numberkeyboard/index.scss +1 -1
  93. package/dist/packages/popover/index.scss +2 -2
  94. package/dist/packages/rate/index.scss +1 -0
  95. package/dist/packages/textarea/index.scss +1 -0
  96. package/dist/packages/timedetail/index.scss +1 -2
  97. package/dist/packages/timeselect/index.scss +3 -0
  98. package/dist/packages/toast/index.scss +6 -0
  99. package/dist/style.css +1 -1
  100. package/dist/style.es.js +2 -1
  101. package/dist/styles/font/config.json +2 -1
  102. package/dist/styles/font/demo_index.html +26 -3
  103. package/dist/styles/font/iconfont.css +7 -3
  104. package/dist/styles/font/iconfont.js +31 -32
  105. package/dist/styles/font/iconfont.json +7 -0
  106. package/dist/styles/font/iconfont.ttf +0 -0
  107. package/dist/styles/font/iconfont.woff +0 -0
  108. package/dist/styles/font/iconfont.woff2 +0 -0
  109. package/dist/styles/themes/default.scss +38 -38
  110. package/dist/styles/variables.scss +5 -1
  111. package/package.json +1 -1
  112. package/dist/packages/_es/commonProps.js +0 -30
  113. package/dist/packages/_es/index.taro.vue_vue&type=script&lang.js +0 -44
  114. package/dist/packages/_es/use-lock-scroll.js +0 -23
@@ -0,0 +1,405 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ /*!
21
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
22
+ * (c) 2021 @jdf2e.
23
+ * Released under the MIT License.
24
+ */
25
+ import { reactive, ref, computed, watch, nextTick, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, createCommentVNode, withDirectives, vShow, normalizeClass, toDisplayString, normalizeStyle, withModifiers } from "vue";
26
+ import { c as createComponent } from "./component.js";
27
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
28
+ const throttle = (func, wait, type) => {
29
+ if (type === 1) {
30
+ var previous = 0;
31
+ } else if (type === 2) {
32
+ var timeout;
33
+ }
34
+ return function() {
35
+ let context = this;
36
+ let args = arguments;
37
+ if (type === 1) {
38
+ let now = Date.now();
39
+ if (now - previous > wait) {
40
+ func.apply(context, args);
41
+ previous = now;
42
+ }
43
+ } else if (type === 2) {
44
+ if (!timeout) {
45
+ timeout = setTimeout(() => {
46
+ timeout = null;
47
+ func.apply(context, args);
48
+ }, wait);
49
+ }
50
+ }
51
+ };
52
+ };
53
+ const { create } = createComponent("video");
54
+ const _sfc_main = create({
55
+ props: {
56
+ source: {
57
+ type: Object,
58
+ default: {}
59
+ },
60
+ options: {
61
+ type: Object,
62
+ default: {
63
+ autoplay: false,
64
+ volume: 0.5,
65
+ poster: "",
66
+ loop: false,
67
+ controls: true,
68
+ muted: false,
69
+ disabled: false,
70
+ playsinline: false,
71
+ touchPlay: false,
72
+ preload: ""
73
+ },
74
+ required: true
75
+ },
76
+ model: {
77
+ type: String,
78
+ default: ""
79
+ }
80
+ },
81
+ components: {},
82
+ emits: ["click", "play", "pause", "playend"],
83
+ setup(props, { emit }) {
84
+ const state = reactive({
85
+ videoElm: null,
86
+ initial: true,
87
+ showToolbox: false,
88
+ player: {
89
+ $player: null,
90
+ pos: null
91
+ },
92
+ progressBar: {
93
+ progressElm: null,
94
+ pos: null
95
+ },
96
+ videoSet: {
97
+ loaded: 0,
98
+ displayTime: "00:00",
99
+ totalTime: "00:00",
100
+ progress: {
101
+ width: 0,
102
+ current: 0
103
+ }
104
+ },
105
+ state: {
106
+ controlShow: true,
107
+ vol: 0.5,
108
+ currentTime: 0,
109
+ fullScreen: false,
110
+ playing: false,
111
+ isLoading: false,
112
+ isEnd: false,
113
+ isError: false,
114
+ isMuted: false
115
+ },
116
+ showTouchMask: false
117
+ });
118
+ const root = ref();
119
+ const isDisabled = computed(() => {
120
+ return props.options.disabled;
121
+ });
122
+ watch(props.source, (newValue) => {
123
+ if (newValue.src) {
124
+ nextTick(() => {
125
+ state.videoElm.load();
126
+ });
127
+ }
128
+ });
129
+ watch(props.options, (newValue) => {
130
+ state.state.isMuted = newValue.muted ? newValue.muted : false;
131
+ }, { immediate: true });
132
+ const init = () => {
133
+ state.videoElm = root.value;
134
+ if (props.options.autoplay) {
135
+ state.videoElm.play();
136
+ }
137
+ if (props.options.touchPlay) {
138
+ state.showTouchMask = true;
139
+ }
140
+ if (props.options.playsinline) {
141
+ state.videoElm.setAttribute("playsinline", props.options.playsinline);
142
+ state.videoElm.setAttribute("webkit-playsinline", props.options.playsinline);
143
+ state.videoElm.setAttribute("x5-video-player-type", "h5-page");
144
+ state.videoElm.setAttribute("x5-video-player-fullscreen", false);
145
+ }
146
+ volumeHandle();
147
+ if (state.showToolbox) {
148
+ customerInit();
149
+ } else {
150
+ state.videoElm.addEventListener("play", () => {
151
+ state.state.playing = true;
152
+ emit("play", state.videoElm);
153
+ });
154
+ state.videoElm.addEventListener("pause", () => {
155
+ state.state.playing = false;
156
+ emit("pause", state.videoElm);
157
+ });
158
+ state.videoElm.addEventListener("ended", playEnded);
159
+ state.videoElm.addEventListener("timeupdate", throttle(getPlayTime, 100, 1));
160
+ }
161
+ };
162
+ const customerInit = () => {
163
+ const $player = root.value;
164
+ const $progress = root.value.getElementsByClassName("progress")[0];
165
+ state.player.$player = $player;
166
+ state.progressBar.progressElm = $progress;
167
+ state.progressBar.pos = $progress.getBoundingClientRect();
168
+ state.videoSet.progress.width = Math.round($progress.getBoundingClientRect().width);
169
+ };
170
+ const play = () => {
171
+ if (props.options.autoplay && props.options.disabled) {
172
+ state.state.playing = true;
173
+ return false;
174
+ }
175
+ state.state.playing = !state.state.playing;
176
+ if (state.videoElm) {
177
+ if (state.state.playing) {
178
+ try {
179
+ state.videoElm.play();
180
+ state.videoElm.addEventListener("progress", () => {
181
+ getLoadTime();
182
+ });
183
+ state.videoElm.addEventListener("timeupdate", throttle(getPlayTime, 100, 1));
184
+ state.videoElm.addEventListener("ended", playEnded);
185
+ emit("play", state.videoElm);
186
+ } catch (e) {
187
+ handleError();
188
+ }
189
+ } else {
190
+ state.videoElm.pause();
191
+ emit("pause", state.videoElm);
192
+ }
193
+ }
194
+ };
195
+ const timeFormat = (t) => {
196
+ var h = Math.floor(t / 3600);
197
+ if (h < 10) {
198
+ h = "0" + h;
199
+ }
200
+ var m = Math.floor(t % 3600 / 60);
201
+ if (m < 10) {
202
+ m = "0" + m;
203
+ }
204
+ var s = Math.round(t % 3600 % 60);
205
+ if (s < 10) {
206
+ s = "0" + s;
207
+ }
208
+ var str = "";
209
+ if (h != 0) {
210
+ str = h + ":" + m + ":" + s;
211
+ } else {
212
+ str = m + ":" + s;
213
+ }
214
+ return str;
215
+ };
216
+ const getLoadTime = () => {
217
+ if (state.videoSet.loaded)
218
+ state.videoSet.loaded = state.videoElm.buffered.end(0) / state.videoElm.duration * 100;
219
+ };
220
+ const getPlayTime = () => {
221
+ const percent = state.videoElm.currentTime / state.videoElm.duration;
222
+ state.videoSet.progress.current = Math.round(state.videoSet.progress.width * percent);
223
+ state.videoSet.totalTime = timeFormat(state.videoElm.duration);
224
+ state.videoSet.displayTime = timeFormat(state.videoElm.currentTime);
225
+ };
226
+ const playEnded = () => {
227
+ state.state.playing = false;
228
+ state.state.isEnd = true;
229
+ state.videoSet.displayTime = "00:00";
230
+ state.videoSet.progress.current = 0;
231
+ state.videoElm.currentTime = 0;
232
+ emit("playend", state.videoElm);
233
+ };
234
+ const handleError = () => {
235
+ state.state.isError = true;
236
+ };
237
+ const volumeHandle = () => {
238
+ state.state.vol = props.options.volume;
239
+ };
240
+ const handleMuted = () => {
241
+ state.state.isMuted = !state.state.isMuted;
242
+ state.videoElm.muted = state.state.isMuted;
243
+ };
244
+ const touchSlidSrart = () => {
245
+ };
246
+ const touchSlidMove = (e) => {
247
+ let currentX = e.targetTouches[0].pageX;
248
+ let offsetX = currentX - state.progressBar.pos.left;
249
+ if (offsetX <= 0) {
250
+ offsetX = 0;
251
+ }
252
+ if (offsetX >= state.videoSet.progress.width) {
253
+ offsetX = state.videoSet.progress.width;
254
+ }
255
+ state.videoSet.progress.current = offsetX;
256
+ let percent = state.videoSet.progress.current / state.videoSet.progress.width;
257
+ state.videoElm.duration && setPlayTime(percent, state.videoElm.duration);
258
+ };
259
+ const touchSlidEnd = (e) => {
260
+ let currentX = e.changedTouches[0].pageX;
261
+ let offsetX = currentX - state.progressBar.pos.left;
262
+ state.videoSet.progress.current = offsetX;
263
+ let percent = offsetX / state.videoSet.progress.width;
264
+ state.videoElm.duration && setPlayTime(percent, state.videoElm.duration);
265
+ };
266
+ const setPlayTime = (percent, totalTime) => {
267
+ state.videoElm.currentTime = Math.floor(percent * totalTime);
268
+ };
269
+ const retry = () => {
270
+ state.state.isError = false;
271
+ init();
272
+ };
273
+ const fullScreen = () => {
274
+ if (!state.state.fullScreen) {
275
+ state.state.fullScreen = true;
276
+ state.videoElm.webkitRequestFullScreen();
277
+ } else {
278
+ state.state.fullScreen = false;
279
+ document.webkitCancelFullScreen();
280
+ }
281
+ };
282
+ onMounted(() => {
283
+ init();
284
+ });
285
+ return __spreadProps(__spreadValues(__spreadValues({
286
+ root
287
+ }, toRefs(props)), toRefs(state)), {
288
+ handleError,
289
+ isDisabled,
290
+ play,
291
+ handleMuted,
292
+ touchSlidSrart,
293
+ touchSlidMove,
294
+ touchSlidEnd,
295
+ retry,
296
+ fullScreen
297
+ });
298
+ }
299
+ });
300
+ const _hoisted_1 = {
301
+ class: "nut-video",
302
+ ref: "videocon"
303
+ };
304
+ const _hoisted_2 = ["muted", "autoplay", "loop", "poster", "controls", "preload"];
305
+ const _hoisted_3 = ["src", "type"];
306
+ const _hoisted_4 = { class: "current-time" };
307
+ const _hoisted_5 = { class: "progress-container" };
308
+ const _hoisted_6 = {
309
+ class: "progress",
310
+ ref: "progressBar"
311
+ };
312
+ const _hoisted_7 = /* @__PURE__ */ createElementVNode("div", { class: "move-handle" }, null, -1);
313
+ const _hoisted_8 = [
314
+ _hoisted_7
315
+ ];
316
+ const _hoisted_9 = {
317
+ class: "played",
318
+ ref: "playedBar"
319
+ };
320
+ const _hoisted_10 = { class: "duration-time" };
321
+ const _hoisted_11 = { class: "nut-video-error" };
322
+ const _hoisted_12 = /* @__PURE__ */ createElementVNode("p", { class: "lose" }, "\u89C6\u9891\u52A0\u8F7D\u5931\u8D25", -1);
323
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
324
+ return openBlock(), createElementBlock("div", _hoisted_1, [
325
+ createElementVNode("video", {
326
+ ref: "root",
327
+ class: "nut-video-player",
328
+ muted: _ctx.options.muted,
329
+ autoplay: _ctx.options.autoplay,
330
+ loop: _ctx.options.loop,
331
+ poster: _ctx.options.poster,
332
+ controls: _ctx.options.controls,
333
+ preload: _ctx.options.preload,
334
+ onError: _cache[0] || (_cache[0] = (...args) => _ctx.handleError && _ctx.handleError(...args))
335
+ }, [
336
+ createElementVNode("source", {
337
+ src: _ctx.source.src,
338
+ type: _ctx.source.type
339
+ }, null, 8, _hoisted_3)
340
+ ], 40, _hoisted_2),
341
+ _ctx.showToolbox && !_ctx.isDisabled ? (openBlock(), createElementBlock("div", {
342
+ key: 0,
343
+ class: "playing-mask",
344
+ ref: "touchMask",
345
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.play && _ctx.play(...args))
346
+ }, null, 512)) : createCommentVNode("", true),
347
+ _ctx.showToolbox && !_ctx.isDisabled ? withDirectives((openBlock(), createElementBlock("div", {
348
+ key: 1,
349
+ class: "nut-video-play-btn",
350
+ ref: "palyBtn",
351
+ onClick: _cache[2] || (_cache[2] = (...args) => _ctx.play && _ctx.play(...args))
352
+ }, null, 512)), [
353
+ [vShow, !_ctx.state.playing]
354
+ ]) : createCommentVNode("", true),
355
+ withDirectives(createElementVNode("div", {
356
+ class: normalizeClass(["nut-video-controller", { "show-control": !_ctx.state.playing, "hide-control": _ctx.state.playing }])
357
+ }, [
358
+ createElementVNode("div", {
359
+ class: "control-play-btn",
360
+ onClick: _cache[3] || (_cache[3] = (...args) => _ctx.play && _ctx.play(...args))
361
+ }),
362
+ createElementVNode("div", _hoisted_4, toDisplayString(_ctx.videoSet.displayTime), 1),
363
+ createElementVNode("div", _hoisted_5, [
364
+ createElementVNode("div", _hoisted_6, [
365
+ createElementVNode("div", {
366
+ class: "buffered",
367
+ style: normalizeStyle({ width: `${_ctx.videoSet.loaded}%` })
368
+ }, null, 4),
369
+ createElementVNode("div", {
370
+ class: "video-ball",
371
+ style: normalizeStyle({
372
+ transform: `translate3d(${_ctx.videoSet.progress.current}px, -50%, 0)`
373
+ }),
374
+ onTouchmove: _cache[4] || (_cache[4] = withModifiers(($event) => _ctx.touchSlidMove($event), ["stop", "prevent"])),
375
+ onTouchstart: _cache[5] || (_cache[5] = withModifiers(($event) => _ctx.touchSlidSrart($event), ["stop"])),
376
+ onTouchend: _cache[6] || (_cache[6] = withModifiers(($event) => _ctx.touchSlidEnd($event), ["stop"]))
377
+ }, _hoisted_8, 36),
378
+ createElementVNode("div", _hoisted_9, null, 512)
379
+ ], 512)
380
+ ]),
381
+ createElementVNode("div", _hoisted_10, toDisplayString(_ctx.videoSet.totalTime), 1),
382
+ createElementVNode("div", {
383
+ class: normalizeClass(["volume", { muted: _ctx.state.isMuted }]),
384
+ onClick: _cache[7] || (_cache[7] = (...args) => _ctx.handleMuted && _ctx.handleMuted(...args))
385
+ }, null, 2),
386
+ createElementVNode("div", {
387
+ class: "fullscreen-icon",
388
+ onClick: _cache[8] || (_cache[8] = (...args) => _ctx.fullScreen && _ctx.fullScreen(...args))
389
+ })
390
+ ], 2), [
391
+ [vShow, _ctx.showToolbox && !_ctx.isDisabled]
392
+ ]),
393
+ withDirectives(createElementVNode("div", _hoisted_11, [
394
+ _hoisted_12,
395
+ createElementVNode("p", {
396
+ class: "retry",
397
+ onClick: _cache[9] || (_cache[9] = (...args) => _ctx.retry && _ctx.retry(...args))
398
+ }, "\u70B9\u51FB\u91CD\u8BD5")
399
+ ], 512), [
400
+ [vShow, _ctx.state.isError]
401
+ ])
402
+ ], 512);
403
+ }
404
+ var Video = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
405
+ export { Video as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,64 +1,13 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { ref } from "vue";
7
- const MIN_DISTANCE = 10;
8
- function getDirection(x, y) {
9
- if (x > y && x > MIN_DISTANCE) {
10
- return "horizontal";
6
+ import { getCurrentInstance } from "vue";
7
+ function useExpose(apis) {
8
+ const instance = getCurrentInstance();
9
+ if (instance) {
10
+ Object.assign(instance.proxy, apis);
11
11
  }
12
- if (y > x && y > MIN_DISTANCE) {
13
- return "vertical";
14
- }
15
- return "";
16
- }
17
- function useTouch() {
18
- const startX = ref(0);
19
- const startY = ref(0);
20
- const deltaX = ref(0);
21
- const deltaY = ref(0);
22
- const offsetX = ref(0);
23
- const offsetY = ref(0);
24
- const direction = ref("");
25
- const isVertical = () => direction.value === "vertical";
26
- const isHorizontal = () => direction.value === "horizontal";
27
- const reset = () => {
28
- deltaX.value = 0;
29
- deltaY.value = 0;
30
- offsetX.value = 0;
31
- offsetY.value = 0;
32
- direction.value = "";
33
- };
34
- const start = (event) => {
35
- reset();
36
- startX.value = event.touches[0].clientX;
37
- startY.value = event.touches[0].clientY;
38
- };
39
- const move = (event) => {
40
- const touch = event.touches[0];
41
- deltaX.value = touch.clientX - startX.value;
42
- deltaY.value = touch.clientY - startY.value;
43
- offsetX.value = Math.abs(deltaX.value);
44
- offsetY.value = Math.abs(deltaY.value);
45
- if (!direction.value) {
46
- direction.value = getDirection(offsetX.value, offsetY.value);
47
- }
48
- };
49
- return {
50
- move,
51
- start,
52
- reset,
53
- startX,
54
- startY,
55
- deltaX,
56
- deltaY,
57
- offsetX,
58
- offsetY,
59
- direction,
60
- isVertical,
61
- isHorizontal
62
- };
63
12
  }
64
- export { useTouch as u };
13
+ export { useExpose as u };
@@ -1,49 +1,64 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
- import { unref } from "vue";
7
- function isWindow(val) {
8
- return val === window;
6
+ import { ref } from "vue";
7
+ const MIN_DISTANCE = 10;
8
+ function getDirection(x, y) {
9
+ if (x > y && x > MIN_DISTANCE) {
10
+ return "horizontal";
11
+ }
12
+ if (y > x && y > MIN_DISTANCE) {
13
+ return "vertical";
14
+ }
15
+ return "";
9
16
  }
10
- const useTaroRect = (elementRef, Taro) => {
11
- let element = unref(elementRef);
12
- return new Promise((resolve) => {
13
- if (Taro.getEnv() === "WEB") {
14
- if (element && element.$el) {
15
- element = element.$el;
16
- }
17
- if (isWindow(element)) {
18
- const width = element.innerWidth;
19
- const height = element.innerHeight;
20
- resolve({
21
- top: 0,
22
- left: 0,
23
- right: width,
24
- bottom: height,
25
- width,
26
- height
27
- });
28
- }
29
- if (element && element.getBoundingClientRect) {
30
- resolve(element.getBoundingClientRect());
31
- }
32
- resolve({
33
- top: 0,
34
- left: 0,
35
- right: 0,
36
- bottom: 0,
37
- width: 0,
38
- height: 0
39
- });
40
- } else {
41
- const query = Taro.createSelectorQuery();
42
- query.select(`#${element.id}`).boundingClientRect();
43
- query.exec(function(res) {
44
- resolve(res[0]);
45
- });
17
+ function useTouch() {
18
+ const startX = ref(0);
19
+ const startY = ref(0);
20
+ const deltaX = ref(0);
21
+ const deltaY = ref(0);
22
+ const offsetX = ref(0);
23
+ const offsetY = ref(0);
24
+ const direction = ref("");
25
+ const isVertical = () => direction.value === "vertical";
26
+ const isHorizontal = () => direction.value === "horizontal";
27
+ const reset = () => {
28
+ deltaX.value = 0;
29
+ deltaY.value = 0;
30
+ offsetX.value = 0;
31
+ offsetY.value = 0;
32
+ direction.value = "";
33
+ };
34
+ const start = (event) => {
35
+ reset();
36
+ startX.value = event.touches[0].clientX;
37
+ startY.value = event.touches[0].clientY;
38
+ };
39
+ const move = (event) => {
40
+ const touch = event.touches[0];
41
+ deltaX.value = touch.clientX - startX.value;
42
+ deltaY.value = touch.clientY - startY.value;
43
+ offsetX.value = Math.abs(deltaX.value);
44
+ offsetY.value = Math.abs(deltaY.value);
45
+ if (!direction.value) {
46
+ direction.value = getDirection(offsetX.value, offsetY.value);
46
47
  }
47
- });
48
- };
49
- export { useTaroRect as u };
48
+ };
49
+ return {
50
+ move,
51
+ start,
52
+ reset,
53
+ startX,
54
+ startY,
55
+ deltaX,
56
+ deltaY,
57
+ offsetX,
58
+ offsetY,
59
+ direction,
60
+ isVertical,
61
+ isHorizontal
62
+ };
63
+ }
64
+ export { useTouch as u };