@nutui/nutui-react-taro 1.3.5 → 1.3.6
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/CHANGELOG.md +7 -0
- package/dist/esm/Audio.js +4 -4
- package/dist/esm/Calendar.js +4 -4
- package/dist/esm/CalendarItem.js +3 -3
- package/dist/esm/DatePicker.js +4 -4
- package/dist/esm/Drag.js +3 -4
- package/dist/esm/Elevator.js +2 -4
- package/dist/esm/NoticeBar.js +3 -3
- package/dist/esm/Picker.js +3 -3
- package/dist/esm/Popover.js +3 -3
- package/dist/esm/Range.js +3 -3
- package/dist/esm/SearchBar.js +3 -2
- package/dist/esm/Signature.js +3 -2
- package/dist/esm/Swipe.js +3 -3
- package/dist/esm/actionsheet.taro-360d8d34.js +15 -25
- package/dist/esm/address.taro-f16cef31.js +151 -219
- package/dist/esm/animatingnumbers.taro-6f40a2e9.js +13 -41
- package/dist/esm/{audio.taro-29f5568f.js → audio.taro-57d4f0da.js} +33 -60
- package/dist/esm/avatar.taro-ec620cdd.js +25 -50
- package/dist/esm/avatargroup-5b2584d9.js +2 -9
- package/dist/esm/backtop.taro-aa8b2bc5.js +29 -55
- package/dist/esm/badge.taro-38684262.js +9 -20
- package/dist/esm/barrage.taro-d86c367a.js +8 -21
- package/dist/esm/button.taro-a9ebb937.js +22 -37
- package/dist/esm/{calendar.taro-438940bd.js → calendar.taro-533b3219.js} +13 -24
- package/dist/esm/{calendaritem.taro-11333579.js → calendaritem.taro-fe5dd4bd.js} +71 -183
- package/dist/esm/card.taro-1bc35ebe.js +14 -20
- package/dist/esm/cascader.taro-77100fb4.js +77 -197
- package/dist/esm/cell.taro-a4c3bb7b.js +20 -30
- package/dist/esm/cellgroup.taro-8c87bf08.js +6 -12
- package/dist/esm/checkbox.taro-104557c1.js +27 -48
- package/dist/esm/checkboxgroup.taro-3d380042.js +12 -30
- package/dist/esm/circleprogress.taro-3c89a157.js +14 -41
- package/dist/esm/col.taro-2a437387.js +11 -22
- package/dist/esm/collapse.taro-72e58ba2.js +11 -27
- package/dist/esm/collapseitem-75843a5e.js +33 -47
- package/dist/esm/configprovider-3e87d67a.js +2 -6
- package/dist/esm/configprovider.taro-6c7b3056.js +4 -14
- package/dist/esm/countdown.taro-f2d9ffed.js +37 -74
- package/dist/esm/{datepicker.taro-1acec61f.js → datepicker.taro-49a4cf0c.js} +43 -104
- package/dist/esm/dialog.taro-492e2b9a.js +27 -58
- package/dist/esm/divider.taro-5236fe6a.js +8 -15
- package/dist/esm/drag.taro-0717c783.js +153 -0
- package/dist/esm/{elevator.taro-8e385785.js → elevator.taro-443253ec.js} +99 -124
- package/dist/esm/empty.taro-ab9c4f03.js +11 -24
- package/dist/esm/fixednav.taro-582322a1.js +16 -27
- package/dist/esm/grid.taro-5d75c0ad.js +13 -28
- package/dist/esm/griditem.taro-866cd288.js +18 -34
- package/dist/esm/icon-8dc4de10.js +11 -21
- package/dist/esm/icon.taro-1d0d4fb7.js +11 -21
- package/dist/esm/imagepreview.taro-1199e977.js +36 -71
- package/dist/esm/indicator.taro-183ea169.js +9 -20
- package/dist/esm/infiniteloading.taro-b95e62bf.js +23 -49
- package/dist/esm/input.taro-2453d7c4.js +62 -106
- package/dist/esm/inputnumber.taro-0cf7c1b7.js +25 -52
- package/dist/esm/layout.taro-358f014f.js +0 -6
- package/dist/esm/menu.taro-9345dcfd.js +21 -41
- package/dist/esm/menuitem.taro-fc0961b7.js +29 -54
- package/dist/esm/navbar.taro-c931c078.js +18 -34
- package/dist/esm/{noticebar.taro-1fa04a96.js → noticebar.taro-332691f9.js} +55 -107
- package/dist/esm/notify.taro-d9c48fae.js +18 -34
- package/dist/esm/numberkeyboard.taro-53c350b8.js +21 -52
- package/dist/esm/nutui-react.es.js +16 -16
- package/dist/esm/offsetContext-0e3d04b3.js +0 -3
- package/dist/esm/overlay.taro-be45fed5.js +12 -23
- package/dist/esm/pagination.taro-62bbd23f.js +38 -71
- package/dist/esm/{picker.taro-6a4dad23.js → picker.taro-f003b725.js} +95 -186
- package/dist/esm/{popover.taro-eddd0bd2.js → popover.taro-7e5dff8c.js} +33 -76
- package/dist/esm/popup.taro-33d0bbc8.js +40 -72
- package/dist/esm/price.taro-97393d8f.js +7 -24
- package/dist/esm/progress.taro-623bc807.js +23 -31
- package/dist/esm/pulltorefresh.taro-e66c78ad.js +29 -92
- package/dist/esm/radio.taro-95d43860.js +24 -47
- package/dist/esm/radiogroup.taro-b5dad516.js +14 -24
- package/dist/esm/{range.taro-515d37a4.js → range.taro-fc7c0b6a.js} +50 -133
- package/dist/esm/rate.taro-69c85081.js +21 -39
- package/dist/esm/row.taro-cec13a7e.js +7 -16
- package/dist/esm/{searchbar.taro-f134fb96.js → searchbar.taro-0d3c0081.js} +55 -70
- package/dist/esm/shortpassword.taro-2e96ca22.js +29 -56
- package/dist/esm/sidenavbar.taro-87f056cd.js +9 -16
- package/dist/esm/sidenavbaritem.taro-77e077f4.js +4 -11
- package/dist/esm/signature.taro-59b3b3ab.js +146 -0
- package/dist/esm/skeleton.taro-b9ff84b9.js +13 -23
- package/dist/esm/step.taro-f1057500.js +12 -28
- package/dist/esm/steps.taro-943f4fbb.js +6 -14
- package/dist/esm/sticky.taro-30d4e453.js +0 -7
- package/dist/esm/subsidenavbar.taro-2c1fcf16.js +7 -22
- package/dist/esm/{swipe.taro-dfb9a049.js → swipe.taro-83bc248f.js} +98 -91
- package/dist/esm/swiper.taro-f314d67a.js +110 -196
- package/dist/esm/swiperitem-d00e7513.js +2 -12
- package/dist/esm/switch.taro-be5eb823.js +13 -27
- package/dist/esm/tabbar.taro-da72fa2c.js +13 -25
- package/dist/esm/tabbaritem.taro-94cd62c2.js +15 -23
- package/dist/esm/table.taro-7ac89a6c.js +19 -39
- package/dist/esm/tabpane.taro-95aa185b.js +4 -10
- package/dist/esm/tabs.taro-86186dff.js +28 -54
- package/dist/esm/tag.taro-95d7f5c2.js +19 -36
- package/dist/esm/textarea.taro-388d1f90.js +18 -35
- package/dist/esm/timedetail.taro-519808cf.js +15 -28
- package/dist/esm/timepannel.taro-9904f6e6.js +5 -12
- package/dist/esm/timeselect.taro-73796bfc.js +35 -59
- package/dist/esm/toast.taro-86862dff.js +26 -46
- package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
- package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +2 -0
- package/dist/esm/types/src/packages/signature/signature.taro.d.ts +10 -2
- package/dist/esm/uploader.taro-6184abe7.js +52 -144
- package/dist/esm/{useClientRect-8b7cc406.js → useClientRect-bf69d7b3.js} +1 -40
- package/dist/esm/useTouch-a2ea68c6.js +27 -47
- package/dist/esm/video-c1090c92.js +8 -19
- package/dist/esm/virtuallist.taro-6858f690.js +84 -118
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/nutui.react.es.js +10844 -11362
- package/dist/nutui.react.umd.js +10844 -11362
- package/dist/packages/searchbar/searchbar.scss +20 -3
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/types/index.d.ts +17 -8
- package/package.json +1 -1
- package/dist/esm/drag.taro-56e8c87a.js +0 -134
- package/dist/esm/signature.taro-a9286cd1.js +0 -178
|
@@ -5,11 +5,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
6
6
|
var _excluded = ["children", "direction", "className", "pageContent", "onChange", "initPage", "paginationColor", "paginationVisible", "touchable", "isPreventDefault", "isStopPropagation", "autoPlay", "isCenter"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
-
|
|
9
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
|
|
11
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
-
|
|
13
10
|
import React__default, { useRef, useState, useMemo, useEffect } from 'react';
|
|
14
11
|
import classNames from 'classnames';
|
|
15
12
|
import { nextTick, useReady, createSelectorQuery } from '@tarojs/taro';
|
|
@@ -34,27 +31,23 @@ var defaultProps = {
|
|
|
34
31
|
var DISTANCE = 5;
|
|
35
32
|
var Swiper = React__default.forwardRef(function (props, ref) {
|
|
36
33
|
var _classNames, _classNames2;
|
|
37
|
-
|
|
38
34
|
var propSwiper = _objectSpread(_objectSpread({}, defaultProps), props);
|
|
39
|
-
|
|
40
35
|
var children = propSwiper.children,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
direction = propSwiper.direction,
|
|
37
|
+
className = propSwiper.className,
|
|
38
|
+
pageContent = propSwiper.pageContent,
|
|
39
|
+
onChange = propSwiper.onChange,
|
|
40
|
+
initPage = propSwiper.initPage,
|
|
41
|
+
paginationColor = propSwiper.paginationColor,
|
|
42
|
+
paginationVisible = propSwiper.paginationVisible,
|
|
43
|
+
touchable = propSwiper.touchable,
|
|
44
|
+
isPreventDefault = propSwiper.isPreventDefault,
|
|
45
|
+
isStopPropagation = propSwiper.isStopPropagation,
|
|
46
|
+
autoPlay = propSwiper.autoPlay,
|
|
47
|
+
isCenter = propSwiper.isCenter,
|
|
48
|
+
rest = _objectWithoutProperties(propSwiper, _excluded);
|
|
55
49
|
var container = useRef(null);
|
|
56
50
|
var innerRef = useRef(null);
|
|
57
|
-
|
|
58
51
|
var _swiper = useRef({
|
|
59
52
|
moving: false,
|
|
60
53
|
autoplayTimer: null,
|
|
@@ -63,104 +56,87 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
63
56
|
offset: 0,
|
|
64
57
|
size: 0
|
|
65
58
|
});
|
|
66
|
-
|
|
67
59
|
var _useState = useState(Math.random().toString(36).slice(-8)),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
61
|
+
refRandomId = _useState2[0];
|
|
71
62
|
var isVertical = direction === 'vertical';
|
|
72
|
-
|
|
73
63
|
var _useState3 = useState(null),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
65
|
+
rect = _useState4[0],
|
|
66
|
+
setRect = _useState4[1];
|
|
67
|
+
// eslint-disable-next-line prefer-const
|
|
79
68
|
var _useState5 = useState(0),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
69
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
70
|
+
active = _useState6[0],
|
|
71
|
+
setActive = _useState6[1];
|
|
84
72
|
var _useState7 = useState(0),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
74
|
+
width = _useState8[0],
|
|
75
|
+
setWidth = _useState8[1];
|
|
89
76
|
var _useState9 = useState(0),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
78
|
+
height = _useState10[0],
|
|
79
|
+
setHeight = _useState10[1];
|
|
94
80
|
var _useState11 = useState(0),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
82
|
+
offset = _useState12[0],
|
|
83
|
+
setOffset = _useState12[1];
|
|
99
84
|
var _useState13 = useState([]),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
86
|
+
childOffset = _useState14[0],
|
|
87
|
+
setChildOffset = _useState14[1];
|
|
104
88
|
var _useState15 = useState(false),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
89
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
90
|
+
ready = _useState16[0],
|
|
91
|
+
setReady = _useState16[1];
|
|
109
92
|
var size = isVertical ? height : width;
|
|
110
|
-
|
|
111
93
|
var _useState17 = useState({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
94
|
+
startX: 0,
|
|
95
|
+
startY: 0,
|
|
96
|
+
deltaX: 0,
|
|
97
|
+
deltaY: 0,
|
|
98
|
+
offsetX: 0,
|
|
99
|
+
offsetY: 0,
|
|
100
|
+
stateDirection: '',
|
|
101
|
+
delta: 0,
|
|
102
|
+
touchTime: 0
|
|
103
|
+
}),
|
|
104
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
105
|
+
touch = _useState18[0],
|
|
106
|
+
setTouch = _useState18[1];
|
|
126
107
|
var _useMemo = useMemo(function () {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
108
|
+
var childCount = 0;
|
|
109
|
+
var childs = React__default.Children.map(props.children, function (child) {
|
|
110
|
+
if (!React__default.isValidElement(child)) return null;
|
|
111
|
+
childCount++;
|
|
112
|
+
return child;
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
childs: childs,
|
|
116
|
+
childCount: childCount
|
|
117
|
+
};
|
|
118
|
+
}, [props.children]),
|
|
119
|
+
childs = _useMemo.childs,
|
|
120
|
+
childCount = _useMemo.childCount;
|
|
121
|
+
var trackSize = childCount * Number(size);
|
|
122
|
+
// 父组件参数传入子组件item
|
|
143
123
|
var parent = {
|
|
144
124
|
propSwiper: propSwiper,
|
|
145
125
|
size: size
|
|
146
126
|
};
|
|
147
|
-
|
|
148
127
|
var minOffset = function () {
|
|
149
128
|
if (rect) {
|
|
150
129
|
var base = isVertical ? rect === null || rect === void 0 ? void 0 : rect.height : rect === null || rect === void 0 ? void 0 : rect.width;
|
|
151
130
|
return base - Number(size) * childCount;
|
|
152
131
|
}
|
|
153
|
-
|
|
154
132
|
return 0;
|
|
155
|
-
}();
|
|
156
|
-
|
|
157
|
-
|
|
133
|
+
}();
|
|
134
|
+
// 清除定时器
|
|
158
135
|
var stopAutoPlay = function stopAutoPlay() {
|
|
159
136
|
clearTimeout(_swiper.current.autoplayTimer);
|
|
160
137
|
_swiper.current.autoplayTimer = null;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
|
|
138
|
+
};
|
|
139
|
+
// 定时轮播
|
|
164
140
|
var autoplay = function autoplay() {
|
|
165
141
|
if (propSwiper.autoPlay <= 0 || childCount <= 1) return;
|
|
166
142
|
stopAutoPlay();
|
|
@@ -168,26 +144,22 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
168
144
|
next();
|
|
169
145
|
autoplay();
|
|
170
146
|
}, Number(propSwiper.autoPlay));
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
};
|
|
148
|
+
// 重置首尾位置信息
|
|
174
149
|
var resettPosition = function resettPosition() {
|
|
175
150
|
_swiper.current.moving = true;
|
|
176
|
-
|
|
177
151
|
if (active <= -1) {
|
|
178
152
|
move({
|
|
179
153
|
pace: childCount
|
|
180
154
|
});
|
|
181
155
|
}
|
|
182
|
-
|
|
183
156
|
if (active >= childCount) {
|
|
184
157
|
move({
|
|
185
158
|
pace: -childCount
|
|
186
159
|
});
|
|
187
160
|
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
|
|
161
|
+
};
|
|
162
|
+
// 上一页
|
|
191
163
|
var prev = function prev() {
|
|
192
164
|
resettPosition();
|
|
193
165
|
touchReset();
|
|
@@ -200,9 +172,8 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
200
172
|
});
|
|
201
173
|
});
|
|
202
174
|
});
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
|
|
175
|
+
};
|
|
176
|
+
// 下一页
|
|
206
177
|
var next = function next() {
|
|
207
178
|
resettPosition();
|
|
208
179
|
touchReset();
|
|
@@ -215,9 +186,8 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
215
186
|
});
|
|
216
187
|
});
|
|
217
188
|
});
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
|
|
189
|
+
};
|
|
190
|
+
// 前往指定页
|
|
221
191
|
var to = function to(index) {
|
|
222
192
|
resettPosition();
|
|
223
193
|
touchReset();
|
|
@@ -225,110 +195,90 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
225
195
|
requestFrame(function () {
|
|
226
196
|
_swiper.current.moving = false;
|
|
227
197
|
var targetIndex;
|
|
228
|
-
|
|
229
198
|
if (props.loop && childCount === index) {
|
|
230
199
|
targetIndex = active === 0 ? 0 : index;
|
|
231
200
|
} else {
|
|
232
201
|
targetIndex = index % childCount;
|
|
233
202
|
}
|
|
234
|
-
|
|
235
203
|
move({
|
|
236
204
|
pace: targetIndex - active,
|
|
237
205
|
isEmit: true
|
|
238
206
|
});
|
|
239
207
|
});
|
|
240
208
|
});
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
|
|
209
|
+
};
|
|
210
|
+
// 切换方法
|
|
244
211
|
var move = function move(_ref) {
|
|
245
212
|
var _ref$pace = _ref.pace,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
213
|
+
pace = _ref$pace === void 0 ? 0 : _ref$pace,
|
|
214
|
+
_ref$offset = _ref.offset,
|
|
215
|
+
offset = _ref$offset === void 0 ? 0 : _ref$offset,
|
|
216
|
+
_ref$isEmit = _ref.isEmit,
|
|
217
|
+
isEmit = _ref$isEmit === void 0 ? false : _ref$isEmit,
|
|
218
|
+
_ref$movingStatus = _ref.movingStatus,
|
|
219
|
+
movingStatus = _ref$movingStatus === void 0 ? false : _ref$movingStatus;
|
|
253
220
|
if (childCount <= 1) return;
|
|
254
|
-
var targetActive = getActive(pace);
|
|
255
|
-
|
|
256
|
-
var targetOffset = getOffset(targetActive, offset);
|
|
257
|
-
|
|
221
|
+
var targetActive = getActive(pace);
|
|
222
|
+
// 父级容器偏移量
|
|
223
|
+
var targetOffset = getOffset(targetActive, offset);
|
|
224
|
+
// 如果循环,调整开头结尾图片位置
|
|
258
225
|
if (props.loop) {
|
|
259
226
|
if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
|
|
260
227
|
var rightBound = targetOffset < minOffset;
|
|
261
228
|
childOffset[0] = rightBound ? trackSize : 0;
|
|
262
229
|
}
|
|
263
|
-
|
|
264
230
|
if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
|
|
265
231
|
var leftBound = targetOffset > 0;
|
|
266
232
|
childOffset[childCount - 1] = leftBound ? -trackSize : 0;
|
|
267
233
|
}
|
|
268
|
-
|
|
269
234
|
setChildOffset(childOffset);
|
|
270
235
|
}
|
|
271
|
-
|
|
272
236
|
if (isEmit && active !== targetActive) {
|
|
273
237
|
props.onChange && props.onChange((targetActive + childCount) % childCount);
|
|
274
238
|
}
|
|
275
|
-
|
|
276
239
|
active = targetActive;
|
|
277
240
|
setActive(targetActive);
|
|
278
241
|
setOffset(targetOffset);
|
|
279
242
|
getStyle(targetOffset);
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
|
|
243
|
+
};
|
|
244
|
+
// 确定当前active 元素
|
|
283
245
|
var getActive = function getActive(pace) {
|
|
284
246
|
if (pace) {
|
|
285
247
|
var _active = active + pace;
|
|
286
|
-
|
|
287
248
|
if (props.loop) {
|
|
288
249
|
return range(_active, -1, childCount);
|
|
289
250
|
}
|
|
290
|
-
|
|
291
251
|
return range(_active, 0, childCount - 1);
|
|
292
252
|
}
|
|
293
|
-
|
|
294
253
|
return active;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
|
|
254
|
+
};
|
|
255
|
+
// 计算位移
|
|
298
256
|
var getOffset = function getOffset(active) {
|
|
299
257
|
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
300
258
|
var currentPosition = active * Number(size);
|
|
301
|
-
|
|
302
259
|
if (!props.loop) {
|
|
303
260
|
currentPosition = Math.min(currentPosition, -minOffset);
|
|
304
261
|
}
|
|
305
|
-
|
|
306
262
|
var targetOffset = offset - currentPosition;
|
|
307
|
-
|
|
308
263
|
if (!props.loop) {
|
|
309
264
|
targetOffset = range(targetOffset, minOffset, 0);
|
|
310
265
|
}
|
|
311
|
-
|
|
312
266
|
return targetOffset;
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
|
|
267
|
+
};
|
|
268
|
+
// 浏览器 帧 事件
|
|
316
269
|
var requestFrame = function requestFrame(fn) {
|
|
317
270
|
window.requestAnimationFrame.call(window, fn);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
|
|
271
|
+
};
|
|
272
|
+
// 取值 方法
|
|
321
273
|
var range = function range(num, min, max) {
|
|
322
274
|
return Math.min(Math.max(num, min), max);
|
|
323
275
|
};
|
|
324
|
-
|
|
325
276
|
var getDirection = function getDirection(x, y) {
|
|
326
277
|
if (x > y && x > DISTANCE) return 'horizontal';
|
|
327
278
|
if (y > x && y > DISTANCE) return 'vertical';
|
|
328
279
|
return '';
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
|
|
280
|
+
};
|
|
281
|
+
// 重置 全部位移信息
|
|
332
282
|
var touchReset = function touchReset() {
|
|
333
283
|
touch.startX = 0;
|
|
334
284
|
touch.startY = 0;
|
|
@@ -339,52 +289,43 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
339
289
|
touch.delta = 0;
|
|
340
290
|
touch.stateDirection = '';
|
|
341
291
|
touch.touchTime = 0;
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
|
|
292
|
+
};
|
|
293
|
+
// 触摸事件开始
|
|
345
294
|
var touchStart = function touchStart(e) {
|
|
346
295
|
touchReset();
|
|
347
296
|
touch.startX = e.touches[0].clientX;
|
|
348
297
|
touch.startY = e.touches[0].clientY;
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
|
|
298
|
+
};
|
|
299
|
+
// 触摸事件移动
|
|
352
300
|
var touchMove = function touchMove(e) {
|
|
353
301
|
touch.deltaX = e.touches[0].clientX - touch.startX;
|
|
354
302
|
touch.deltaY = e.touches[0].clientY - touch.startY;
|
|
355
303
|
touch.offsetX = Math.abs(touch.deltaX);
|
|
356
304
|
touch.offsetY = Math.abs(touch.deltaY);
|
|
357
305
|
touch.delta = isVertical ? touch.deltaY : touch.deltaX;
|
|
358
|
-
|
|
359
306
|
if (!touch.stateDirection) {
|
|
360
307
|
touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
|
|
361
308
|
}
|
|
362
309
|
};
|
|
363
|
-
|
|
364
310
|
var b = cn('swiper');
|
|
365
311
|
var classes = classNames(b(''));
|
|
366
312
|
var contentClass = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b('inner')), true), _defineProperty(_classNames, "".concat(b('vertical')), isVertical), _classNames));
|
|
367
|
-
|
|
368
313
|
var getStyle = function getStyle() {
|
|
369
314
|
var moveOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : offset;
|
|
370
315
|
var target = innerRef.current;
|
|
371
316
|
var _offset = 0;
|
|
372
|
-
|
|
373
317
|
if (!isCenter) {
|
|
374
318
|
_offset = moveOffset;
|
|
375
319
|
} else {
|
|
376
320
|
var _size = isVertical ? height : width;
|
|
377
|
-
|
|
378
321
|
var val = isVertical ? (rect === null || rect === void 0 ? void 0 : rect.height) - _size : (rect === null || rect === void 0 ? void 0 : rect.width) - _size;
|
|
379
322
|
_offset = moveOffset + (active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
|
|
380
323
|
}
|
|
381
|
-
|
|
382
324
|
target.style.transitionDuration = "".concat(_swiper.current.moving ? 0 : props.duration, "ms");
|
|
383
325
|
target.style[isVertical ? 'height' : 'width'] = "".concat(Number(size) * childCount, "px");
|
|
384
326
|
target.style[isVertical ? 'width' : 'height'] = "".concat(isVertical ? width : height, "px");
|
|
385
327
|
target.style.transform = "translate3D".concat(!isVertical ? "(".concat(_offset, "px,0,0)") : "(0,".concat(_offset, "px,0)"));
|
|
386
328
|
};
|
|
387
|
-
|
|
388
329
|
var onTouchStart = function onTouchStart(e) {
|
|
389
330
|
if (props.isPreventDefault) e.preventDefault();
|
|
390
331
|
if (props.isStopPropagation) e.stopPropagation();
|
|
@@ -394,11 +335,9 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
394
335
|
stopAutoPlay();
|
|
395
336
|
resettPosition();
|
|
396
337
|
};
|
|
397
|
-
|
|
398
338
|
var onTouchMove = function onTouchMove(e) {
|
|
399
339
|
if (props.touchable && _swiper.current.moving) {
|
|
400
340
|
touchMove(e);
|
|
401
|
-
|
|
402
341
|
if (touch.stateDirection === props.direction) {
|
|
403
342
|
move({
|
|
404
343
|
offset: touch.delta
|
|
@@ -406,17 +345,14 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
406
345
|
}
|
|
407
346
|
}
|
|
408
347
|
};
|
|
409
|
-
|
|
410
348
|
var onTouchEnd = function onTouchEnd(e) {
|
|
411
349
|
if (!props.touchable || !_swiper.current.moving) return;
|
|
412
350
|
var speed = touch.delta / (Date.now() - touch.touchTime);
|
|
413
351
|
var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
|
|
414
352
|
var pace = 0;
|
|
415
353
|
_swiper.current.moving = false;
|
|
416
|
-
|
|
417
354
|
if (isShouldMove && touch.stateDirection === props.direction) {
|
|
418
355
|
var _offset2 = isVertical ? touch.offsetY : touch.offsetX;
|
|
419
|
-
|
|
420
356
|
if (props.loop) {
|
|
421
357
|
if (_offset2 > 0) {
|
|
422
358
|
pace = touch.delta > 0 ? -1 : 1;
|
|
@@ -426,7 +362,6 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
426
362
|
} else {
|
|
427
363
|
pace = -Math[touch.delta > 0 ? 'ceil' : 'floor'](touch.delta / size);
|
|
428
364
|
}
|
|
429
|
-
|
|
430
365
|
move({
|
|
431
366
|
pace: pace,
|
|
432
367
|
isEmit: true
|
|
@@ -438,14 +373,11 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
438
373
|
} else {
|
|
439
374
|
getStyle();
|
|
440
375
|
}
|
|
441
|
-
|
|
442
376
|
autoplay();
|
|
443
377
|
};
|
|
444
|
-
|
|
445
378
|
useEffect(function () {
|
|
446
379
|
_swiper.current.activePagination = (active + childCount) % childCount;
|
|
447
380
|
}, [active]);
|
|
448
|
-
|
|
449
381
|
var queryRect = function queryRect(element) {
|
|
450
382
|
return new Promise(function (resolve) {
|
|
451
383
|
var query = createSelectorQuery();
|
|
@@ -455,17 +387,15 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
455
387
|
});
|
|
456
388
|
});
|
|
457
389
|
};
|
|
458
|
-
|
|
459
390
|
var init = /*#__PURE__*/function () {
|
|
460
391
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
461
392
|
var active,
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
393
|
+
rect,
|
|
394
|
+
_active,
|
|
395
|
+
_width,
|
|
396
|
+
_height,
|
|
397
|
+
targetOffset,
|
|
398
|
+
_args = arguments;
|
|
469
399
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
470
400
|
while (1) {
|
|
471
401
|
switch (_context.prev = _context.next) {
|
|
@@ -473,7 +403,6 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
473
403
|
active = _args.length > 0 && _args[0] !== undefined ? _args[0] : +propSwiper.initPage;
|
|
474
404
|
_context.next = 3;
|
|
475
405
|
return queryRect(container.current);
|
|
476
|
-
|
|
477
406
|
case 3:
|
|
478
407
|
rect = _context.sent;
|
|
479
408
|
_active = Math.max(Math.min(childCount - 1, active), 0);
|
|
@@ -483,18 +412,15 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
483
412
|
trackSize = childCount * Number(size);
|
|
484
413
|
targetOffset = getOffset(_active);
|
|
485
414
|
_swiper.current.moving = true;
|
|
486
|
-
|
|
487
415
|
if (ready) {
|
|
488
416
|
_swiper.current.moving = false;
|
|
489
417
|
}
|
|
490
|
-
|
|
491
418
|
setRect(rect);
|
|
492
419
|
setActive(_active);
|
|
493
420
|
setWidth(_width);
|
|
494
421
|
setHeight(_height);
|
|
495
422
|
setOffset(targetOffset);
|
|
496
423
|
setReady(true);
|
|
497
|
-
|
|
498
424
|
case 18:
|
|
499
425
|
case "end":
|
|
500
426
|
return _context.stop();
|
|
@@ -502,12 +428,10 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
502
428
|
}
|
|
503
429
|
}, _callee);
|
|
504
430
|
}));
|
|
505
|
-
|
|
506
431
|
return function init() {
|
|
507
432
|
return _ref2.apply(this, arguments);
|
|
508
433
|
};
|
|
509
434
|
}();
|
|
510
|
-
|
|
511
435
|
useEffect(function () {
|
|
512
436
|
if (ready) {
|
|
513
437
|
getStyle();
|
|
@@ -518,7 +442,6 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
518
442
|
stopAutoPlay();
|
|
519
443
|
autoplay();
|
|
520
444
|
}
|
|
521
|
-
|
|
522
445
|
return function () {
|
|
523
446
|
setReady(false);
|
|
524
447
|
};
|
|
@@ -542,27 +465,19 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
542
465
|
init();
|
|
543
466
|
});
|
|
544
467
|
});
|
|
545
|
-
|
|
546
468
|
var itemStyle = function itemStyle(index) {
|
|
547
469
|
var style = {};
|
|
548
|
-
|
|
549
470
|
var _direction = propSwiper.direction || direction;
|
|
550
|
-
|
|
551
471
|
var _size = size;
|
|
552
|
-
|
|
553
472
|
if (_size) {
|
|
554
473
|
style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
|
|
555
474
|
}
|
|
556
|
-
|
|
557
475
|
var offset = childOffset[index];
|
|
558
|
-
|
|
559
476
|
if (offset) {
|
|
560
477
|
style.transform = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
|
|
561
478
|
}
|
|
562
|
-
|
|
563
479
|
return style;
|
|
564
480
|
};
|
|
565
|
-
|
|
566
481
|
React__default.useImperativeHandle(ref, function () {
|
|
567
482
|
return {
|
|
568
483
|
to: to,
|
|
@@ -595,7 +510,6 @@ var Swiper = React__default.forwardRef(function (props, ref) {
|
|
|
595
510
|
className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b('pagination')), true), _defineProperty(_classNames2, "".concat(b('pagination-vertical')), isVertical), _classNames2))
|
|
596
511
|
}, React__default.Children.map(childs, function (item, index) {
|
|
597
512
|
var _classNames3;
|
|
598
|
-
|
|
599
513
|
return React__default.createElement("i", {
|
|
600
514
|
style: (active + childCount) % childCount === index ? {
|
|
601
515
|
backgroundColor: propSwiper.paginationColor
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import React__default, { useContext } from 'react';
|
|
8
5
|
import classNames from 'classnames';
|
|
9
6
|
import { D as DataContext } from './UserContext-b4181162.js';
|
|
@@ -13,28 +10,21 @@ var defaultProps = {
|
|
|
13
10
|
};
|
|
14
11
|
var SwiperItem = React__default.forwardRef(function (props, ref) {
|
|
15
12
|
var _props = _objectSpread(_objectSpread({}, defaultProps), props);
|
|
16
|
-
|
|
17
13
|
var children = _props.children,
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
direction = _props.direction,
|
|
15
|
+
size = _props.size;
|
|
20
16
|
var parent = useContext(DataContext);
|
|
21
17
|
var b = cn('swiper-item');
|
|
22
18
|
var classes = classNames(b(''));
|
|
23
|
-
|
|
24
19
|
var style = function style() {
|
|
25
20
|
var style = {};
|
|
26
|
-
|
|
27
21
|
var _direction = (parent === null || parent === void 0 ? void 0 : parent.propSwiper.direction) || direction;
|
|
28
|
-
|
|
29
22
|
var _size = (parent === null || parent === void 0 ? void 0 : parent.size) || size;
|
|
30
|
-
|
|
31
23
|
if (_size) {
|
|
32
24
|
style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
return style;
|
|
36
27
|
};
|
|
37
|
-
|
|
38
28
|
return React__default.createElement("div", {
|
|
39
29
|
className: classes,
|
|
40
30
|
style: style()
|