@nutui/nutui 4.0.0-beta.7 → 4.0.0-beta.9
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/dist/nutui.es.js +125 -0
- package/dist/nutui.umd.cjs +7 -20046
- package/dist/packages/_es/Barrage.js +15 -27
- package/dist/packages/_es/Dialog.js +11 -16
- package/dist/packages/_es/ImagePreview.js +10 -13
- package/dist/packages/_es/Notify.js +6 -5
- package/dist/packages/_es/Swiper.js +56 -114
- package/dist/packages/_es/Switch.js +1 -1
- package/dist/packages/_es/Toast.js +6 -7
- package/dist/packages/barrage/index.scss +17 -1
- package/dist/packages/cell/index.scss +3 -1
- package/dist/packages/dialog/index.mjs +2 -1
- package/dist/packages/imagepreview/index.mjs +2 -1
- package/dist/packages/notify/index.mjs +2 -1
- package/dist/packages/pullrefresh/index.scss +3 -2
- package/dist/packages/toast/index.mjs +2 -1
- package/dist/smartips/attributes.json +25 -21
- package/dist/smartips/tags.json +9 -8
- package/dist/smartips/web-types.json +38 -29
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +53 -53
- package/dist/styles/themes/jdb.scss +53 -53
- package/dist/styles/themes/jddkh.scss +53 -53
- package/dist/styles/themes/jdt.scss +53 -53
- package/dist/types/__VUE/barrage/index.vue.d.ts +0 -1
- package/dist/types/__VUE/dialog/index.d.ts +9 -9
- package/dist/types/__VUE/imagepreview/index.d.ts +12 -12
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +0 -9
- package/dist/types/__VUE/notify/index.d.ts +3 -3
- package/dist/types/__VUE/swiper/index.vue.d.ts +8 -7
- package/dist/types/__VUE/toast/index.d.ts +3 -3
- package/dist/types/index.d.ts +10 -6
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useSlots, computed, ref, onMounted, onUnmounted, onDeactivated, watch, nextTick,
|
|
1
|
+
import { useSlots, computed, ref, onMounted, onUnmounted, onDeactivated, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createCommentVNode } from "vue";
|
|
2
2
|
import { c as createComponent } from "./component-81a4c1d0.js";
|
|
3
3
|
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
|
|
4
4
|
import "../locale/lang";
|
|
5
5
|
const { componentName, create } = createComponent("barrage");
|
|
6
|
-
const
|
|
6
|
+
const _sfc_main = create({
|
|
7
7
|
name: "barrage",
|
|
8
8
|
props: {
|
|
9
9
|
danmu: {
|
|
@@ -66,6 +66,8 @@ const __default__ = create({
|
|
|
66
66
|
danmuList.value = dmList;
|
|
67
67
|
}
|
|
68
68
|
setTimeout(() => {
|
|
69
|
+
var _a2;
|
|
70
|
+
(_a2 = dmBody.value) == null ? void 0 : _a2.style.setProperty("--move-distance", `-${danmuCWidth.value}px`);
|
|
69
71
|
run();
|
|
70
72
|
}, 300);
|
|
71
73
|
});
|
|
@@ -98,14 +100,13 @@ const __default__ = create({
|
|
|
98
100
|
const run = () => {
|
|
99
101
|
clearInterval(timer);
|
|
100
102
|
timer = 0;
|
|
101
|
-
timer =
|
|
103
|
+
timer = setTimeout(() => {
|
|
102
104
|
play();
|
|
103
105
|
run();
|
|
104
106
|
}, props.frequency);
|
|
105
107
|
};
|
|
106
|
-
const distance = ref("0");
|
|
107
108
|
const play = () => {
|
|
108
|
-
var _a
|
|
109
|
+
var _a;
|
|
109
110
|
if (!props.loop && index2.value >= danmuList.value.length) {
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
@@ -113,13 +114,7 @@ const __default__ = create({
|
|
|
113
114
|
let el = document.createElement(`view`);
|
|
114
115
|
if (slotDefault && typeof danmuList.value[_index] == "object") {
|
|
115
116
|
el = danmuList.value[_index];
|
|
116
|
-
|
|
117
|
-
el.classList.remove("nut-barrage__item");
|
|
118
|
-
}
|
|
119
|
-
if ((_b = el == null ? void 0 : el.classList) == null ? void 0 : _b.contains("move")) {
|
|
120
|
-
el.classList.remove("move");
|
|
121
|
-
}
|
|
122
|
-
(_c = el == null ? void 0 : el.classList) == null ? void 0 : _c.add("nut-barrage__item");
|
|
117
|
+
(_a = el == null ? void 0 : el.classList) == null ? void 0 : _a.add("nut-barrage__item");
|
|
123
118
|
} else {
|
|
124
119
|
el.innerHTML = danmuList.value[_index];
|
|
125
120
|
el.classList.add("nut-barrage__item");
|
|
@@ -136,11 +131,15 @@ const __default__ = create({
|
|
|
136
131
|
const width = el.offsetWidth;
|
|
137
132
|
el.style.width = width + 20 + "px";
|
|
138
133
|
}
|
|
139
|
-
el.style.setProperty("--move-distance", `-${danmuCWidth.value}px`);
|
|
140
|
-
distance.value = "-" + speeds / 1e3 * 150 + "%";
|
|
141
134
|
el.dataset.index = `${_index}`;
|
|
142
135
|
if (slotDefault) {
|
|
143
136
|
index2.value++;
|
|
137
|
+
el.addEventListener("animationend", () => {
|
|
138
|
+
var _a3;
|
|
139
|
+
if ((_a3 = el == null ? void 0 : el.classList) == null ? void 0 : _a3.contains("move")) {
|
|
140
|
+
el.classList.remove("move");
|
|
141
|
+
}
|
|
142
|
+
});
|
|
144
143
|
} else {
|
|
145
144
|
el.addEventListener("animationend", () => {
|
|
146
145
|
dmContainer.value.removeChild(el);
|
|
@@ -149,20 +148,9 @@ const __default__ = create({
|
|
|
149
148
|
}
|
|
150
149
|
});
|
|
151
150
|
};
|
|
152
|
-
return { classTime, classes, danmuList, dmBody, dmContainer, add
|
|
151
|
+
return { classTime, classes, danmuList, dmBody, dmContainer, add };
|
|
153
152
|
}
|
|
154
153
|
});
|
|
155
|
-
const __injectCSSVars__ = () => {
|
|
156
|
-
useCssVars((_ctx) => ({
|
|
157
|
-
"9e8362c8": _ctx.distance
|
|
158
|
-
}));
|
|
159
|
-
};
|
|
160
|
-
const __setup__ = __default__.setup;
|
|
161
|
-
__default__.setup = __setup__ ? (props, ctx) => {
|
|
162
|
-
__injectCSSVars__();
|
|
163
|
-
return __setup__(props, ctx);
|
|
164
|
-
} : __injectCSSVars__;
|
|
165
|
-
const index_vue_vue_type_style_index_0_lang = "";
|
|
166
154
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
167
155
|
return openBlock(), createElementBlock("div", {
|
|
168
156
|
ref: "dmBody",
|
|
@@ -181,7 +169,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
181
169
|
], 2)
|
|
182
170
|
], 2);
|
|
183
171
|
}
|
|
184
|
-
const index = /* @__PURE__ */ _export_sfc(
|
|
172
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
185
173
|
export {
|
|
186
174
|
index as default
|
|
187
175
|
};
|
|
@@ -235,16 +235,11 @@ class DialogOptions {
|
|
|
235
235
|
__publicField(this, "teleport", "body");
|
|
236
236
|
__publicField(this, "id", new Date().getTime());
|
|
237
237
|
__publicField(this, "footerDirection", "horizontal");
|
|
238
|
-
__publicField(this, "onUpdate"
|
|
239
|
-
|
|
240
|
-
__publicField(this, "
|
|
241
|
-
|
|
242
|
-
__publicField(this, "
|
|
243
|
-
});
|
|
244
|
-
__publicField(this, "onOpened", () => {
|
|
245
|
-
});
|
|
246
|
-
__publicField(this, "onClosed", () => {
|
|
247
|
-
});
|
|
238
|
+
__publicField(this, "onUpdate");
|
|
239
|
+
__publicField(this, "onOk");
|
|
240
|
+
__publicField(this, "onCancel");
|
|
241
|
+
__publicField(this, "onOpened");
|
|
242
|
+
__publicField(this, "onClosed");
|
|
248
243
|
__publicField(this, "beforeClose");
|
|
249
244
|
__publicField(this, "visible", true);
|
|
250
245
|
__publicField(this, "noFooter", false);
|
|
@@ -259,7 +254,7 @@ class DialogFunction {
|
|
|
259
254
|
constructor(_options) {
|
|
260
255
|
__publicField(this, "options", new DialogOptions());
|
|
261
256
|
__publicField(this, "instance");
|
|
262
|
-
|
|
257
|
+
const options = Object.assign(this.options, _options);
|
|
263
258
|
const { unmount } = CreateComponent(options, {
|
|
264
259
|
name: "dialog",
|
|
265
260
|
components: [Popup, Button, Overlay],
|
|
@@ -284,15 +279,15 @@ class DialogFunction {
|
|
|
284
279
|
});
|
|
285
280
|
}
|
|
286
281
|
}
|
|
287
|
-
const
|
|
282
|
+
const showDialog = function(options) {
|
|
288
283
|
return new DialogFunction(options);
|
|
289
284
|
};
|
|
290
|
-
|
|
285
|
+
showDialog.install = (app) => {
|
|
291
286
|
app.use(Dialog);
|
|
292
|
-
app.config.globalProperties.$dialog =
|
|
287
|
+
app.config.globalProperties.$dialog = showDialog;
|
|
293
288
|
};
|
|
294
289
|
export {
|
|
295
|
-
Dialog,
|
|
296
290
|
DialogOptions,
|
|
297
|
-
|
|
291
|
+
Dialog as default,
|
|
292
|
+
showDialog
|
|
298
293
|
};
|
|
@@ -19,6 +19,7 @@ import "../locale/lang";
|
|
|
19
19
|
import { C as CreateComponent } from "./mountComponent-1ece4110.js";
|
|
20
20
|
import Overlay from "./Overlay.js";
|
|
21
21
|
import "./index-79c5dc33.js";
|
|
22
|
+
import "./raf-729dad54.js";
|
|
22
23
|
const baseProps = {
|
|
23
24
|
show: { type: Boolean, default: false },
|
|
24
25
|
initNo: { type: Number, default: 0 },
|
|
@@ -291,10 +292,6 @@ const _sfc_main = create({
|
|
|
291
292
|
type: Boolean,
|
|
292
293
|
default: false
|
|
293
294
|
},
|
|
294
|
-
closeIcon: {
|
|
295
|
-
type: String,
|
|
296
|
-
default: "circle-close"
|
|
297
|
-
},
|
|
298
295
|
closeIconPosition: {
|
|
299
296
|
type: String,
|
|
300
297
|
default: "top-right"
|
|
@@ -351,6 +348,7 @@ const _sfc_main = create({
|
|
|
351
348
|
const init = () => {
|
|
352
349
|
if (swipeRef.value) {
|
|
353
350
|
const rect = useRect(swipeRef.value);
|
|
351
|
+
console.log("show");
|
|
354
352
|
state.rootHeight = rect.height;
|
|
355
353
|
state.rootWidth = rect.width;
|
|
356
354
|
}
|
|
@@ -358,6 +356,7 @@ const _sfc_main = create({
|
|
|
358
356
|
watch(
|
|
359
357
|
() => props.show,
|
|
360
358
|
(val) => {
|
|
359
|
+
console.log("展示", val);
|
|
361
360
|
state.showPop = val;
|
|
362
361
|
init();
|
|
363
362
|
}
|
|
@@ -471,8 +470,6 @@ class ImagePreviewOptions {
|
|
|
471
470
|
__publicField(this, "maxZoom", 3);
|
|
472
471
|
__publicField(this, "minZoom", 1 / 3);
|
|
473
472
|
__publicField(this, "isLoop", true);
|
|
474
|
-
__publicField(this, "onClose", () => {
|
|
475
|
-
});
|
|
476
473
|
__publicField(this, "teleport", "body");
|
|
477
474
|
}
|
|
478
475
|
}
|
|
@@ -480,8 +477,8 @@ class ImagePreviewFunction {
|
|
|
480
477
|
constructor(_options) {
|
|
481
478
|
__publicField(this, "options", new ImagePreviewOptions());
|
|
482
479
|
const options = Object.assign(this.options, _options);
|
|
483
|
-
const {
|
|
484
|
-
name: "
|
|
480
|
+
const { unmount } = CreateComponent(options, {
|
|
481
|
+
name: "image-preview",
|
|
485
482
|
components: [Popup, Video, Swiper, SwiperItem, Overlay],
|
|
486
483
|
wrapper: () => {
|
|
487
484
|
return {
|
|
@@ -498,13 +495,13 @@ class ImagePreviewFunction {
|
|
|
498
495
|
});
|
|
499
496
|
}
|
|
500
497
|
}
|
|
501
|
-
const
|
|
502
|
-
|
|
498
|
+
const showImagePreview = (options) => new ImagePreviewFunction(options);
|
|
499
|
+
showImagePreview.install = (app) => {
|
|
503
500
|
app.use(ImagePreview);
|
|
504
|
-
app.config.globalProperties.$imagepreview =
|
|
501
|
+
app.config.globalProperties.$imagepreview = showImagePreview;
|
|
505
502
|
};
|
|
506
503
|
export {
|
|
507
|
-
ImagePreview,
|
|
508
504
|
ImagePreviewOptions,
|
|
509
|
-
|
|
505
|
+
ImagePreview as default,
|
|
506
|
+
showImagePreview
|
|
510
507
|
};
|
|
@@ -108,6 +108,7 @@ const defaultOptions = {
|
|
|
108
108
|
background: void 0,
|
|
109
109
|
duration: 3e3,
|
|
110
110
|
className: "",
|
|
111
|
+
onClose: Function,
|
|
111
112
|
teleport: "",
|
|
112
113
|
unmount: new Function()
|
|
113
114
|
};
|
|
@@ -168,6 +169,7 @@ const mountNotify = (opts) => {
|
|
|
168
169
|
opts.teleport = `#notify-${opts.id}`;
|
|
169
170
|
onMounted(() => {
|
|
170
171
|
setTimeout(() => {
|
|
172
|
+
opts.onClose && opts.onClose();
|
|
171
173
|
document.body.removeChild(root);
|
|
172
174
|
}, opts.duration);
|
|
173
175
|
});
|
|
@@ -186,7 +188,7 @@ const errorMsg = (msg) => {
|
|
|
186
188
|
return;
|
|
187
189
|
}
|
|
188
190
|
};
|
|
189
|
-
const
|
|
191
|
+
const showNotify = {
|
|
190
192
|
text(msg, obj = {}) {
|
|
191
193
|
errorMsg(msg);
|
|
192
194
|
return mountNotify({ ...obj, msg });
|
|
@@ -212,11 +214,10 @@ const NotifyFunction = {
|
|
|
212
214
|
},
|
|
213
215
|
install(app) {
|
|
214
216
|
app.use(Notify);
|
|
215
|
-
app.config.globalProperties.$notify =
|
|
217
|
+
app.config.globalProperties.$notify = showNotify;
|
|
216
218
|
}
|
|
217
219
|
};
|
|
218
220
|
export {
|
|
219
|
-
Notify,
|
|
220
|
-
|
|
221
|
-
NotifyFunction as default
|
|
221
|
+
Notify as default,
|
|
222
|
+
showNotify
|
|
222
223
|
};
|
|
@@ -1,56 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createComponent } from "./component-81a4c1d0.js";
|
|
1
|
+
import { ref, reactive, computed, provide, onDeactivated, onBeforeUnmount, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, renderSlot, Fragment, renderList, createCommentVNode } from "vue";
|
|
2
|
+
import { c as createComponent, e as clamp } from "./component-81a4c1d0.js";
|
|
3
|
+
import { u as useTouch } from "./index-7a7385e4.js";
|
|
3
4
|
import { u as useExpose } from "./index-79c5dc33.js";
|
|
5
|
+
import { r as requestAniFrame } from "./raf-729dad54.js";
|
|
4
6
|
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
|
|
5
7
|
import "../locale/lang";
|
|
6
|
-
const DISTANCE = 5;
|
|
7
|
-
function useTouch() {
|
|
8
|
-
const state = reactive({
|
|
9
|
-
startX: 0,
|
|
10
|
-
startY: 0,
|
|
11
|
-
deltaX: 0,
|
|
12
|
-
deltaY: 0,
|
|
13
|
-
offsetX: 0,
|
|
14
|
-
offsetY: 0,
|
|
15
|
-
direction: ""
|
|
16
|
-
});
|
|
17
|
-
const getDirection = (x, y) => {
|
|
18
|
-
if (x > y && x > DISTANCE)
|
|
19
|
-
return "horizontal";
|
|
20
|
-
if (y > x && y > DISTANCE)
|
|
21
|
-
return "vertical";
|
|
22
|
-
return "";
|
|
23
|
-
};
|
|
24
|
-
const reset = () => {
|
|
25
|
-
state.startX = 0;
|
|
26
|
-
state.startY = 0;
|
|
27
|
-
state.deltaX = 0;
|
|
28
|
-
state.deltaY = 0;
|
|
29
|
-
state.offsetX = 0;
|
|
30
|
-
state.offsetY = 0;
|
|
31
|
-
state.direction = "";
|
|
32
|
-
};
|
|
33
|
-
const start = (e) => {
|
|
34
|
-
reset();
|
|
35
|
-
state.startX = e.touches[0].clientX;
|
|
36
|
-
state.startY = e.touches[0].clientY;
|
|
37
|
-
};
|
|
38
|
-
const move = (e) => {
|
|
39
|
-
state.deltaX = e.touches[0].clientX - state.startX;
|
|
40
|
-
state.deltaY = e.touches[0].clientY - state.startY;
|
|
41
|
-
state.offsetX = Math.abs(state.deltaX);
|
|
42
|
-
state.offsetY = Math.abs(state.deltaY);
|
|
43
|
-
if (!state.direction) {
|
|
44
|
-
state.direction = getDirection(state.offsetX, state.offsetY);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
state,
|
|
49
|
-
start,
|
|
50
|
-
reset,
|
|
51
|
-
move
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
8
|
const { create, componentName } = createComponent("swiper");
|
|
55
9
|
const _sfc_main = create({
|
|
56
10
|
props: {
|
|
@@ -63,7 +17,7 @@ const _sfc_main = create({
|
|
|
63
17
|
default: 0
|
|
64
18
|
},
|
|
65
19
|
direction: {
|
|
66
|
-
type:
|
|
20
|
+
type: String,
|
|
67
21
|
default: "horizontal"
|
|
68
22
|
},
|
|
69
23
|
paginationVisible: {
|
|
@@ -132,11 +86,25 @@ const _sfc_main = create({
|
|
|
132
86
|
};
|
|
133
87
|
});
|
|
134
88
|
const isVertical = computed(() => props.direction === "vertical");
|
|
89
|
+
const classesInner = computed(() => {
|
|
90
|
+
const prefixCls = componentName;
|
|
91
|
+
return {
|
|
92
|
+
[`${prefixCls}-inner`]: true,
|
|
93
|
+
[`${prefixCls}-vertical`]: isVertical.value
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
const classesPagination = computed(() => {
|
|
97
|
+
const prefixCls = componentName;
|
|
98
|
+
return {
|
|
99
|
+
[`${prefixCls}-pagination`]: true,
|
|
100
|
+
[`${prefixCls}-pagination-vertical`]: isVertical.value
|
|
101
|
+
};
|
|
102
|
+
});
|
|
135
103
|
const delTa = computed(() => {
|
|
136
|
-
return isVertical.value ? touch.
|
|
104
|
+
return isVertical.value ? touch.deltaY.value : touch.deltaX.value;
|
|
137
105
|
});
|
|
138
106
|
const isCorrectDirection = computed(() => {
|
|
139
|
-
return touch.
|
|
107
|
+
return touch.direction.value === props.direction;
|
|
140
108
|
});
|
|
141
109
|
const childCount = computed(() => state.children.length);
|
|
142
110
|
const size = computed(() => state[isVertical.value ? "height" : "width"]);
|
|
@@ -151,12 +119,7 @@ const _sfc_main = create({
|
|
|
151
119
|
const activePagination = computed(() => (state.active + childCount.value) % childCount.value);
|
|
152
120
|
const getStyle = () => {
|
|
153
121
|
let offset = 0;
|
|
154
|
-
|
|
155
|
-
offset = state.offset;
|
|
156
|
-
} else {
|
|
157
|
-
let val = isVertical.value ? state.rect.height - size.value : state.rect.width - size.value;
|
|
158
|
-
offset = state.offset + (state.active === childCount.value - 1 ? -val / 2 : val / 2);
|
|
159
|
-
}
|
|
122
|
+
offset = state.offset;
|
|
160
123
|
state.style = {
|
|
161
124
|
transitionDuration: `${state.moving ? 0 : props.duration}ms`,
|
|
162
125
|
transform: `translate${isVertical.value ? "Y" : "X"}(${offset}px)`,
|
|
@@ -167,26 +130,27 @@ const _sfc_main = create({
|
|
|
167
130
|
const relation = (child) => {
|
|
168
131
|
var _a;
|
|
169
132
|
let children = [];
|
|
133
|
+
const childrenVNodeLen = state.childrenVNode.length;
|
|
170
134
|
let slot = (_a = slots == null ? void 0 : slots.default) == null ? void 0 : _a.call(slots);
|
|
171
135
|
slot = slot.filter((item) => item.children && Array.isArray(item.children));
|
|
172
136
|
slot.forEach((item) => {
|
|
173
137
|
children = children.concat(item.children);
|
|
174
138
|
});
|
|
175
|
-
if (!
|
|
139
|
+
if (!childrenVNodeLen) {
|
|
176
140
|
state.childrenVNode = children.slice();
|
|
177
141
|
child.proxy && state.children.push(child.proxy);
|
|
178
142
|
} else {
|
|
179
|
-
if (
|
|
143
|
+
if (childrenVNodeLen > children.length) {
|
|
180
144
|
state.children = state.children.filter((item) => child.proxy !== item);
|
|
181
|
-
} else if (
|
|
182
|
-
for (let i = 0; i <
|
|
145
|
+
} else if (childrenVNodeLen < children.length) {
|
|
146
|
+
for (let i = 0; i < childrenVNodeLen; i++) {
|
|
183
147
|
if (children[i].key !== state.childrenVNode[i].key) {
|
|
184
148
|
child.proxy && state.children.splice(i, 0, child.proxy);
|
|
185
149
|
child.vnode && state.childrenVNode.splice(i, 0, child.vnode);
|
|
186
150
|
break;
|
|
187
151
|
}
|
|
188
152
|
}
|
|
189
|
-
if (
|
|
153
|
+
if (childrenVNodeLen !== children.length) {
|
|
190
154
|
child.proxy && state.children.push(child.proxy);
|
|
191
155
|
child.vnode && state.childrenVNode.push(child.vnode);
|
|
192
156
|
}
|
|
@@ -196,12 +160,6 @@ const _sfc_main = create({
|
|
|
196
160
|
}
|
|
197
161
|
}
|
|
198
162
|
};
|
|
199
|
-
const range = (num, min, max) => {
|
|
200
|
-
return Math.min(Math.max(num, min), max);
|
|
201
|
-
};
|
|
202
|
-
const requestFrame = (fn) => {
|
|
203
|
-
window.requestAnimationFrame.call(window, fn);
|
|
204
|
-
};
|
|
205
163
|
const getOffset = (active, offset = 0) => {
|
|
206
164
|
let currentPosition = active * size.value;
|
|
207
165
|
if (!props.loop) {
|
|
@@ -209,7 +167,7 @@ const _sfc_main = create({
|
|
|
209
167
|
}
|
|
210
168
|
let targetOffset = offset - currentPosition;
|
|
211
169
|
if (!props.loop) {
|
|
212
|
-
targetOffset =
|
|
170
|
+
targetOffset = clamp(targetOffset, minOffset.value, 0);
|
|
213
171
|
}
|
|
214
172
|
return targetOffset;
|
|
215
173
|
};
|
|
@@ -217,9 +175,9 @@ const _sfc_main = create({
|
|
|
217
175
|
const { active } = state;
|
|
218
176
|
if (pace) {
|
|
219
177
|
if (props.loop) {
|
|
220
|
-
return
|
|
178
|
+
return clamp(active + pace, -1, childCount.value);
|
|
221
179
|
}
|
|
222
|
-
return
|
|
180
|
+
return clamp(active + pace, 0, childCount.value - 1);
|
|
223
181
|
}
|
|
224
182
|
return active;
|
|
225
183
|
};
|
|
@@ -258,48 +216,39 @@ const _sfc_main = create({
|
|
|
258
216
|
const stopAutoPlay = () => {
|
|
259
217
|
clearTimeout(state.autoplayTimer);
|
|
260
218
|
};
|
|
261
|
-
const
|
|
219
|
+
const jump = (pace) => {
|
|
262
220
|
resettPosition();
|
|
263
221
|
touch.reset();
|
|
264
|
-
|
|
265
|
-
|
|
222
|
+
requestAniFrame(() => {
|
|
223
|
+
requestAniFrame(() => {
|
|
266
224
|
state.moving = false;
|
|
267
225
|
move({
|
|
268
|
-
pace
|
|
226
|
+
pace,
|
|
269
227
|
isEmit: true
|
|
270
228
|
});
|
|
271
229
|
});
|
|
272
230
|
});
|
|
273
231
|
};
|
|
232
|
+
const prev = () => {
|
|
233
|
+
jump(-1);
|
|
234
|
+
};
|
|
274
235
|
const next = () => {
|
|
275
|
-
|
|
276
|
-
touch.reset();
|
|
277
|
-
requestFrame(() => {
|
|
278
|
-
requestFrame(() => {
|
|
279
|
-
state.moving = false;
|
|
280
|
-
move({
|
|
281
|
-
pace: 1,
|
|
282
|
-
isEmit: true
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
});
|
|
236
|
+
jump(1);
|
|
286
237
|
};
|
|
287
238
|
const to = (index) => {
|
|
288
239
|
resettPosition();
|
|
289
240
|
touch.reset();
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
isEmit: true
|
|
302
|
-
});
|
|
241
|
+
requestAniFrame(() => {
|
|
242
|
+
state.moving = false;
|
|
243
|
+
let targetIndex;
|
|
244
|
+
if (props.loop && childCount.value === index) {
|
|
245
|
+
targetIndex = state.active === 0 ? 0 : index;
|
|
246
|
+
} else {
|
|
247
|
+
targetIndex = index % childCount.value;
|
|
248
|
+
}
|
|
249
|
+
move({
|
|
250
|
+
pace: targetIndex - state.active,
|
|
251
|
+
isEmit: true
|
|
303
252
|
});
|
|
304
253
|
});
|
|
305
254
|
};
|
|
@@ -353,7 +302,7 @@ const _sfc_main = create({
|
|
|
353
302
|
const isShouldMove = Math.abs(speed) > 0.3 || Math.abs(delTa.value) > +(size.value / 2).toFixed(2);
|
|
354
303
|
if (isShouldMove && isCorrectDirection.value) {
|
|
355
304
|
let pace = 0;
|
|
356
|
-
const offset = isVertical.value ? touch.
|
|
305
|
+
const offset = isVertical.value ? touch.offsetY.value : touch.offsetX.value;
|
|
357
306
|
if (props.loop) {
|
|
358
307
|
pace = offset > 0 ? delTa.value > 0 ? -1 : 1 : 0;
|
|
359
308
|
} else {
|
|
@@ -411,10 +360,9 @@ const _sfc_main = create({
|
|
|
411
360
|
return {
|
|
412
361
|
state,
|
|
413
362
|
classes,
|
|
363
|
+
classesInner,
|
|
364
|
+
classesPagination,
|
|
414
365
|
container,
|
|
415
|
-
componentName,
|
|
416
|
-
isVertical,
|
|
417
|
-
slots,
|
|
418
366
|
activePagination,
|
|
419
367
|
onTouchStart,
|
|
420
368
|
onTouchMove,
|
|
@@ -432,21 +380,15 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
432
380
|
onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args))
|
|
433
381
|
}, [
|
|
434
382
|
createElementVNode("view", {
|
|
435
|
-
class: normalizeClass(
|
|
436
|
-
[`${_ctx.componentName}-inner`]: true,
|
|
437
|
-
[`${_ctx.componentName}-vertical`]: _ctx.isVertical
|
|
438
|
-
}),
|
|
383
|
+
class: normalizeClass(_ctx.classesInner),
|
|
439
384
|
style: normalizeStyle(_ctx.state.style)
|
|
440
385
|
}, [
|
|
441
386
|
renderSlot(_ctx.$slots, "default")
|
|
442
387
|
], 6),
|
|
443
388
|
renderSlot(_ctx.$slots, "page"),
|
|
444
|
-
_ctx.paginationVisible && !_ctx
|
|
389
|
+
_ctx.paginationVisible && !_ctx.$slots.page ? (openBlock(), createElementBlock("view", {
|
|
445
390
|
key: 0,
|
|
446
|
-
class: normalizeClass(
|
|
447
|
-
[`${_ctx.componentName}-pagination`]: true,
|
|
448
|
-
[`${_ctx.componentName}-pagination-vertical`]: _ctx.isVertical
|
|
449
|
-
})
|
|
391
|
+
class: normalizeClass(_ctx.classesPagination)
|
|
450
392
|
}, [
|
|
451
393
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.state.children.length, (item, index) => {
|
|
452
394
|
return openBlock(), createElementBlock("i", {
|
|
@@ -97,7 +97,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
97
97
|
}, [
|
|
98
98
|
createElementVNode("view", _hoisted_1, [
|
|
99
99
|
_ctx.loading ? renderSlot(_ctx.$slots, "icon", { key: 0 }, () => [
|
|
100
|
-
createVNode(_component_Loading1)
|
|
100
|
+
createVNode(_component_Loading1, { name: "loading" })
|
|
101
101
|
]) : createCommentVNode("", true),
|
|
102
102
|
_ctx.activeText ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
103
103
|
withDirectives(createElementVNode("view", { class: "nut-switch-label open" }, toDisplayString(_ctx.activeText), 513), [
|
|
@@ -245,7 +245,7 @@ const updateToast = (opts) => {
|
|
|
245
245
|
}
|
|
246
246
|
const instance = createVNode(Toast, opts);
|
|
247
247
|
render(instance, container);
|
|
248
|
-
return
|
|
248
|
+
return showToast;
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
const mountToast = (opts) => {
|
|
@@ -266,7 +266,7 @@ const mountToast = (opts) => {
|
|
|
266
266
|
CreateComponent(opts, {
|
|
267
267
|
wrapper: Toast
|
|
268
268
|
});
|
|
269
|
-
return
|
|
269
|
+
return showToast;
|
|
270
270
|
};
|
|
271
271
|
const errorMsg = (msg) => {
|
|
272
272
|
if (!msg) {
|
|
@@ -274,7 +274,7 @@ const errorMsg = (msg) => {
|
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
|
-
const
|
|
277
|
+
const showToast = {
|
|
278
278
|
text(msg, opts = {}) {
|
|
279
279
|
errorMsg(msg);
|
|
280
280
|
return mountToast({ ...opts, type: "text", msg });
|
|
@@ -304,11 +304,10 @@ const ToastFunction = {
|
|
|
304
304
|
},
|
|
305
305
|
install(app) {
|
|
306
306
|
app.use(Toast);
|
|
307
|
-
app.config.globalProperties.$toast =
|
|
307
|
+
app.config.globalProperties.$toast = showToast;
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
export {
|
|
311
|
-
Toast,
|
|
312
|
-
|
|
313
|
-
ToastFunction as default
|
|
311
|
+
Toast as default,
|
|
312
|
+
showToast
|
|
314
313
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
height: 100%;
|
|
7
7
|
overflow: hidden;
|
|
8
8
|
box-sizing: border-box;
|
|
9
|
-
|
|
9
|
+
--move-distance: '300%';
|
|
10
10
|
&__item {
|
|
11
11
|
width: 100px;
|
|
12
12
|
display: block;
|
|
@@ -25,6 +25,22 @@
|
|
|
25
25
|
animation-timing-function: linear;
|
|
26
26
|
animation-play-state: running;
|
|
27
27
|
}
|
|
28
|
+
@keyframes moving {
|
|
29
|
+
from {
|
|
30
|
+
transform: translateX(100%);
|
|
31
|
+
}
|
|
32
|
+
to {
|
|
33
|
+
transform: translateX(var(--move-distance));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
@-webkit-keyframes moving {
|
|
37
|
+
from {
|
|
38
|
+
-webkit-transform: translateX(100%);
|
|
39
|
+
}
|
|
40
|
+
to {
|
|
41
|
+
transform: translateX(var(--move-distance));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
28
44
|
}
|
|
29
45
|
}
|
|
30
46
|
.nut-theme-dark {
|
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
&__icon {
|
|
73
73
|
display: flex;
|
|
74
74
|
flex-direction: row;
|
|
75
|
-
margin
|
|
75
|
+
margin: $cell-default-icon-margin;
|
|
76
|
+
align-items: center;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
&__title {
|
|
@@ -94,5 +95,6 @@
|
|
|
94
95
|
}
|
|
95
96
|
&__link {
|
|
96
97
|
color: #979797;
|
|
98
|
+
align-self: center;
|
|
97
99
|
}
|
|
98
100
|
}
|