@nutui/nutui-react-taro 1.3.0-beta.5 → 1.3.1-beta.1
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 +28 -0
- package/dist/esm/Address.js +4 -4
- package/dist/esm/Audio/style/index.js +4 -0
- package/dist/esm/Audio.js +18 -0
- package/dist/esm/AvatarGroup.js +4 -4
- package/dist/esm/Calendar/style/index.js +1 -2
- package/dist/esm/Calendar.js +6 -5
- package/dist/esm/CalendarItem.js +5 -5
- package/dist/esm/Cascader/style/index.js +2 -0
- package/dist/esm/Cascader.js +14 -0
- package/dist/esm/ConfigProvider.js +3 -3
- package/dist/esm/CountDown.js +4 -4
- package/dist/esm/DatePicker.js +4 -4
- package/dist/esm/Dialog.js +4 -4
- package/dist/esm/Empty.js +4 -4
- package/dist/esm/FixedNav.js +4 -4
- package/dist/esm/Grid/style/index.js +2 -0
- package/dist/esm/Grid.js +7 -0
- package/dist/esm/GridItem/style/index.js +2 -0
- package/dist/esm/GridItem.js +8 -0
- package/dist/esm/ImagePreview/style/index.js +2 -0
- package/dist/esm/ImagePreview.js +15 -0
- package/dist/esm/Infiniteloading.js +4 -4
- package/dist/esm/Input.js +4 -4
- package/dist/esm/Menu/style/index.js +3 -0
- package/dist/esm/Menu.js +7 -0
- package/dist/esm/MenuItem/style/index.js +3 -0
- package/dist/esm/MenuItem.js +11 -0
- package/dist/esm/NoticeBar.js +3 -2
- package/dist/esm/{Notification-dccc7625.js → Notification-422905bd.js} +2 -1
- package/dist/esm/Notify.js +3 -2
- package/dist/esm/NumberKeyboard.js +4 -4
- package/dist/esm/Pagination.js +4 -4
- package/dist/esm/Picker.js +4 -4
- package/dist/esm/Popover.js +3 -2
- package/dist/esm/Range.js +7 -5
- package/dist/esm/SearchBar.js +4 -4
- package/dist/esm/ShortPassword.js +4 -4
- package/dist/esm/SideNavBar.js +4 -4
- package/dist/esm/Signature.js +4 -4
- package/dist/esm/Swipe/style/index.js +2 -0
- package/dist/esm/Swipe.js +7 -0
- package/dist/esm/Swiper.js +3 -2
- package/dist/esm/Table.js +4 -4
- package/dist/esm/TextArea.js +4 -4
- package/dist/esm/TimeDetail.js +4 -4
- package/dist/esm/TimePannel.js +4 -4
- package/dist/esm/TimeSelect.js +4 -4
- package/dist/esm/Toast.js +4 -3
- package/dist/esm/Uploader.js +4 -4
- package/dist/esm/VirtualList.js +4 -4
- package/dist/esm/{address.taro-a1092e30.js → address.taro-4765a826.js} +17 -6
- package/dist/esm/audio.taro-cd6cc93b.js +292 -0
- package/dist/esm/{avatargroup-65173caa.js → avatargroup-1ca79066.js} +1 -1
- package/dist/esm/calendar.taro-1abb1925.js +89 -0
- package/dist/esm/{calendaritem.taro-fe84d94b.js → calendaritem.taro-3c06a809.js} +130 -5
- package/dist/esm/cascader.taro-31dbc60e.js +786 -0
- package/dist/esm/{configprovider-18657611.js → configprovider-9c393a29.js} +1 -1
- package/dist/esm/{configprovider.taro-98343012.js → configprovider.taro-1ff7f150.js} +2 -2
- package/dist/esm/{countdown.taro-cd6a1bd4.js → countdown.taro-b00d0d46.js} +1 -1
- package/dist/esm/{datepicker.taro-c1249537.js → datepicker.taro-e385849d.js} +1 -1
- package/dist/esm/{dialog.taro-5b850861.js → dialog.taro-c80b7b5f.js} +12 -18
- package/dist/esm/{empty.taro-6f86eda5.js → empty.taro-20b8adac.js} +1 -1
- package/dist/esm/{fixednav.taro-ca94fd6a.js → fixednav.taro-75e35339.js} +1 -1
- package/dist/esm/grid.taro-7fb43d02.js +90 -0
- package/dist/esm/griditem.taro-8020b409.js +98 -0
- package/dist/esm/imagepreview.taro-a0ddd8a2.js +813 -0
- package/dist/esm/{infiniteloading.taro-d2c0ca14.js → infiniteloading.taro-0a86819e.js} +1 -1
- package/dist/esm/{input.taro-2e31ebbb.js → input.taro-1d23861d.js} +1 -1
- package/dist/esm/menu.taro-03e3b011.js +153 -0
- package/dist/esm/menuitem.taro-56bf3205.js +195 -0
- package/dist/esm/{noticebar.taro-ae593896.js → noticebar.taro-1890c693.js} +3 -2
- package/dist/esm/{notify.taro-95b5f97e.js → notify.taro-22b8f4cd.js} +2 -1
- package/dist/esm/{numberkeyboard.taro-71b2e0eb.js → numberkeyboard.taro-5d685c76.js} +1 -1
- package/dist/esm/nutui-react.es.js +45 -36
- package/dist/esm/{pagination.taro-abc4a71e.js → pagination.taro-10449c4a.js} +1 -1
- package/dist/esm/{picker.taro-0eb8bfa3.js → picker.taro-216cc3cb.js} +1 -1
- package/dist/esm/{popover.taro-4c102df6.js → popover.taro-9b3da0fa.js} +17 -71
- package/dist/esm/{range.taro-034fcf7a.js → range.taro-fe08c5f4.js} +118 -110
- package/dist/esm/render-4a3856cb.js +32 -0
- package/dist/esm/{searchbar.taro-4c6091cb.js → searchbar.taro-450d2f88.js} +1 -1
- package/dist/esm/{shortpassword.taro-ce46b9cd.js → shortpassword.taro-08a05360.js} +23 -18
- package/dist/esm/{sidenavbar.taro-36f1e118.js → sidenavbar.taro-dd471476.js} +1 -1
- package/dist/esm/{signature.taro-45aedfa9.js → signature.taro-7cb77bab.js} +1 -1
- package/dist/esm/swipe.taro-dfb9a049.js +264 -0
- package/dist/esm/{swiper.taro-59bf2777.js → swiper.taro-7a2ef124.js} +2 -1
- package/dist/esm/{table.taro-49009dfc.js → table.taro-305e0317.js} +1 -1
- package/dist/esm/{textarea.taro-0c40e966.js → textarea.taro-700b04c2.js} +1 -1
- package/dist/esm/{timedetail.taro-0e31b4a5.js → timedetail.taro-7cc00243.js} +1 -1
- package/dist/esm/{timepannel.taro-2d54b3db.js → timepannel.taro-e24537e4.js} +1 -1
- package/dist/esm/{timeselect.taro-c35d3490.js → timeselect.taro-210fd548.js} +1 -1
- package/dist/esm/{toast.taro-48539c09.js → toast.taro-bb181833.js} +1 -1
- package/dist/esm/{uploader.taro-ece83a00.js → uploader.taro-f7528535.js} +1 -1
- package/dist/esm/useClientRect-8b7cc406.js +74 -0
- package/dist/esm/{virtuallist.taro-2ff1a5ad.js → virtuallist.taro-ce9619f9.js} +1 -1
- package/dist/esm/{zh-CN-f5124686.js → zh-CN-91090ae2.js} +16 -0
- package/dist/locales/base.d.ts +16 -0
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +17 -1
- package/dist/locales/id-ID.js +17 -1
- package/dist/locales/zh-CN.js +17 -1
- package/dist/locales/zh-TW.js +17 -1
- package/dist/nutui.react.es.js +5595 -4062
- package/dist/nutui.react.umd.js +20243 -30
- package/dist/packages/audio/audio.scss +80 -0
- package/dist/packages/calendar/calendar.scss +57 -36
- package/dist/packages/calendaritem/calendaritem.scss +0 -191
- package/dist/packages/cascader/cascader.scss +69 -0
- package/dist/packages/grid/grid.scss +10 -0
- package/dist/packages/griditem/griditem.scss +103 -0
- package/dist/packages/imagepreview/imagepreview.scss +51 -0
- package/dist/packages/menu/menu.scss +72 -0
- package/dist/packages/menuitem/menuitem.scss +90 -0
- package/dist/packages/popup/popup.scss +1 -1
- package/dist/packages/searchbar/searchbar.scss +1 -0
- package/dist/packages/shortpassword/shortpassword.scss +6 -1
- package/dist/packages/swipe/swipe.scss +33 -0
- package/dist/packages/textarea/textarea.scss +16 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/font/iconfont.js +20 -18
- package/dist/styles/themes/default.scss +8 -0
- package/dist/styles/variables.scss +59 -8
- package/dist/types/audio/audio.taro.d.ts +18 -0
- package/dist/types/audio/index.taro.d.ts +2 -0
- package/dist/types/cascader/cascader.taro.d.ts +25 -0
- package/dist/types/cascader/cascaderItem.taro.d.ts +25 -0
- package/dist/types/cascader/index.taro.d.ts +2 -0
- package/dist/types/checkbox/checkbox.taro.d.ts +2 -2
- package/dist/types/checkboxgroup/checkboxgroup.taro.d.ts +2 -2
- package/dist/types/dialog/dialog.taro.d.ts +2 -1
- package/dist/types/grid/grid.taro.d.ts +16 -0
- package/dist/types/grid/index.taro.d.ts +2 -0
- package/dist/types/griditem/griditem.taro.d.ts +20 -0
- package/dist/types/griditem/index.taro.d.ts +2 -0
- package/dist/types/icon/icon.taro.d.ts +1 -2
- package/dist/types/imagepreview/imagepreview.taro.d.ts +26 -0
- package/dist/types/imagepreview/index.taro.d.ts +2 -0
- package/dist/types/menu/index.taro.d.ts +2 -0
- package/dist/types/menu/menu.taro.d.ts +12 -0
- package/dist/types/menuitem/index.taro.d.ts +2 -0
- package/dist/types/menuitem/menuitem.taro.d.ts +23 -0
- package/dist/types/notify/notify.taro.d.ts +13 -0
- package/dist/types/nutui.react.d.ts +95 -1
- package/dist/types/picker/picker.taro.d.ts +2 -2
- package/dist/types/popup/popup.taro.d.ts +1 -1
- package/dist/types/shortpassword/shortpassword.taro.d.ts +3 -3
- package/dist/types/sidenavbar/sidenavbar.taro.d.ts +14 -2
- package/dist/types/sidenavbaritem/sidenavbaritem.taro.d.ts +10 -2
- package/dist/types/subsidenavbar/subsidenavbar.taro.d.ts +13 -3
- package/dist/types/swipe/index.taro.d.ts +2 -0
- package/dist/types/swipe/swipe.taro.d.ts +41 -0
- package/dist/types/table/table.taro.d.ts +2 -1
- package/dist/types/toast/toast.taro.d.ts +18 -0
- package/dist/types/virtuallist/virtuallist.taro.d.ts +2 -1
- package/package.json +4 -4
- package/dist/esm/calendar.taro-4b2103c1.js +0 -621
- package/dist/esm/raf-3fbb5f92.js +0 -126
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
5
|
+
var _excluded = ["children", "direction", "className", "pageContent", "onChange", "initPage", "paginationColor", "paginationVisible", "touchable", "isPreventDefault", "isStopPropagation", "autoPlay", "isCenter"];
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
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; }
|
|
10
|
+
|
|
11
|
+
import React__default, { useRef, useState, useMemo, useEffect } from 'react';
|
|
12
|
+
import { P as Popup } from './popup-67173ec6.js';
|
|
13
|
+
import { V as Video } from './video-c1090c92.js';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { D as DataContext } from './UserContext-b4181162.js';
|
|
16
|
+
import { c as cn } from './bem-893ad28d.js';
|
|
17
|
+
import { a as getRect } from './useClientRect-8b7cc406.js';
|
|
18
|
+
import { S as SwiperItem } from './swiperitem-d00e7513.js';
|
|
19
|
+
var defaultProps$1 = {
|
|
20
|
+
width: (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' ? window.innerWidth : 375,
|
|
21
|
+
height: 0,
|
|
22
|
+
duration: 500,
|
|
23
|
+
initPage: 0,
|
|
24
|
+
autoPlay: 0,
|
|
25
|
+
direction: 'horizontal',
|
|
26
|
+
paginationColor: '#fff',
|
|
27
|
+
paginationVisible: false,
|
|
28
|
+
loop: true,
|
|
29
|
+
touchable: true,
|
|
30
|
+
isPreventDefault: true,
|
|
31
|
+
isStopPropagation: true,
|
|
32
|
+
isCenter: false,
|
|
33
|
+
className: ''
|
|
34
|
+
};
|
|
35
|
+
var DISTANCE = 5;
|
|
36
|
+
var Swiper = React__default.forwardRef(function (props, ref) {
|
|
37
|
+
var _classNames, _classNames2;
|
|
38
|
+
|
|
39
|
+
var propSwiper = _objectSpread(_objectSpread({}, defaultProps$1), props);
|
|
40
|
+
|
|
41
|
+
var children = propSwiper.children,
|
|
42
|
+
direction = propSwiper.direction,
|
|
43
|
+
className = propSwiper.className,
|
|
44
|
+
pageContent = propSwiper.pageContent,
|
|
45
|
+
onChange = propSwiper.onChange,
|
|
46
|
+
initPage = propSwiper.initPage,
|
|
47
|
+
paginationColor = propSwiper.paginationColor,
|
|
48
|
+
paginationVisible = propSwiper.paginationVisible,
|
|
49
|
+
touchable = propSwiper.touchable,
|
|
50
|
+
isPreventDefault = propSwiper.isPreventDefault,
|
|
51
|
+
isStopPropagation = propSwiper.isStopPropagation,
|
|
52
|
+
autoPlay = propSwiper.autoPlay,
|
|
53
|
+
isCenter = propSwiper.isCenter,
|
|
54
|
+
rest = _objectWithoutProperties(propSwiper, _excluded);
|
|
55
|
+
|
|
56
|
+
var container = useRef(null);
|
|
57
|
+
var innerRef = useRef(null);
|
|
58
|
+
|
|
59
|
+
var _swiper = useRef({
|
|
60
|
+
moving: false,
|
|
61
|
+
autoplayTimer: null,
|
|
62
|
+
width: 0,
|
|
63
|
+
height: 0,
|
|
64
|
+
offset: 0,
|
|
65
|
+
size: 0
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
var isVertical = direction === 'vertical';
|
|
69
|
+
|
|
70
|
+
var _useState = useState(null),
|
|
71
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
+
rect = _useState2[0],
|
|
73
|
+
setRect = _useState2[1]; // eslint-disable-next-line prefer-const
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
var _useState3 = useState(0),
|
|
77
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
78
|
+
active = _useState4[0],
|
|
79
|
+
setActive = _useState4[1];
|
|
80
|
+
|
|
81
|
+
var _useState5 = useState(0),
|
|
82
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
83
|
+
width = _useState6[0],
|
|
84
|
+
setWidth = _useState6[1];
|
|
85
|
+
|
|
86
|
+
var _useState7 = useState(0),
|
|
87
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
88
|
+
height = _useState8[0],
|
|
89
|
+
setHeight = _useState8[1];
|
|
90
|
+
|
|
91
|
+
var _useState9 = useState(0),
|
|
92
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
93
|
+
offset = _useState10[0],
|
|
94
|
+
setOffset = _useState10[1];
|
|
95
|
+
|
|
96
|
+
var _useState11 = useState([]),
|
|
97
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
98
|
+
childOffset = _useState12[0],
|
|
99
|
+
setChildOffset = _useState12[1];
|
|
100
|
+
|
|
101
|
+
var _useState13 = useState(false),
|
|
102
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
103
|
+
ready = _useState14[0],
|
|
104
|
+
setReady = _useState14[1];
|
|
105
|
+
|
|
106
|
+
var size = isVertical ? height : width;
|
|
107
|
+
|
|
108
|
+
var _useState15 = useState({
|
|
109
|
+
startX: 0,
|
|
110
|
+
startY: 0,
|
|
111
|
+
deltaX: 0,
|
|
112
|
+
deltaY: 0,
|
|
113
|
+
offsetX: 0,
|
|
114
|
+
offsetY: 0,
|
|
115
|
+
stateDirection: '',
|
|
116
|
+
delta: 0,
|
|
117
|
+
touchTime: 0
|
|
118
|
+
}),
|
|
119
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
120
|
+
touch = _useState16[0],
|
|
121
|
+
setTouch = _useState16[1];
|
|
122
|
+
|
|
123
|
+
var _useMemo = useMemo(function () {
|
|
124
|
+
var childCount = 0;
|
|
125
|
+
var childs = React__default.Children.map(props.children, function (child) {
|
|
126
|
+
if (!React__default.isValidElement(child)) return null;
|
|
127
|
+
childCount++;
|
|
128
|
+
return child;
|
|
129
|
+
});
|
|
130
|
+
return {
|
|
131
|
+
childs: childs,
|
|
132
|
+
childCount: childCount
|
|
133
|
+
};
|
|
134
|
+
}, [props.children]),
|
|
135
|
+
childs = _useMemo.childs,
|
|
136
|
+
childCount = _useMemo.childCount;
|
|
137
|
+
|
|
138
|
+
var trackSize = childCount * Number(size); // 父组件参数传入子组件item
|
|
139
|
+
|
|
140
|
+
var parent = {
|
|
141
|
+
propSwiper: propSwiper,
|
|
142
|
+
size: size
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var minOffset = function () {
|
|
146
|
+
if (rect) {
|
|
147
|
+
var base = isVertical ? rect.height : rect.width;
|
|
148
|
+
return base - Number(size) * childCount;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return 0;
|
|
152
|
+
}(); // 清除定时器
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
var stopAutoPlay = function stopAutoPlay() {
|
|
156
|
+
clearTimeout(_swiper.current.autoplayTimer);
|
|
157
|
+
_swiper.current.autoplayTimer = null;
|
|
158
|
+
}; // 定时轮播
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
var autoplay = function autoplay() {
|
|
162
|
+
if (propSwiper.autoPlay <= 0 || childCount <= 1) return;
|
|
163
|
+
stopAutoPlay();
|
|
164
|
+
_swiper.current.autoplayTimer = setTimeout(function () {
|
|
165
|
+
next();
|
|
166
|
+
autoplay();
|
|
167
|
+
}, Number(propSwiper.autoPlay));
|
|
168
|
+
}; // 重置首尾位置信息
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
var resettPosition = function resettPosition() {
|
|
172
|
+
_swiper.current.moving = true;
|
|
173
|
+
|
|
174
|
+
if (active <= -1) {
|
|
175
|
+
move({
|
|
176
|
+
pace: childCount
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (active >= childCount) {
|
|
181
|
+
move({
|
|
182
|
+
pace: -childCount
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}; // 上一页
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
var prev = function prev() {
|
|
189
|
+
resettPosition();
|
|
190
|
+
touchReset();
|
|
191
|
+
requestFrame(function () {
|
|
192
|
+
requestFrame(function () {
|
|
193
|
+
_swiper.current.moving = false;
|
|
194
|
+
move({
|
|
195
|
+
pace: -1,
|
|
196
|
+
isEmit: true
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}; // 下一页
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
var next = function next() {
|
|
204
|
+
resettPosition();
|
|
205
|
+
touchReset();
|
|
206
|
+
requestFrame(function () {
|
|
207
|
+
requestFrame(function () {
|
|
208
|
+
_swiper.current.moving = false;
|
|
209
|
+
move({
|
|
210
|
+
pace: 1,
|
|
211
|
+
isEmit: true
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}; // 前往指定页
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
var to = function to(index) {
|
|
219
|
+
resettPosition();
|
|
220
|
+
touchReset();
|
|
221
|
+
requestFrame(function () {
|
|
222
|
+
requestFrame(function () {
|
|
223
|
+
_swiper.current.moving = false;
|
|
224
|
+
var targetIndex;
|
|
225
|
+
|
|
226
|
+
if (props.loop && childCount === index) {
|
|
227
|
+
targetIndex = active === 0 ? 0 : index;
|
|
228
|
+
} else {
|
|
229
|
+
targetIndex = index % childCount;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
move({
|
|
233
|
+
pace: targetIndex - active,
|
|
234
|
+
isEmit: true
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}; // 切换方法
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
var move = function move(_ref) {
|
|
242
|
+
var _ref$pace = _ref.pace,
|
|
243
|
+
pace = _ref$pace === void 0 ? 0 : _ref$pace,
|
|
244
|
+
_ref$offset = _ref.offset,
|
|
245
|
+
offset = _ref$offset === void 0 ? 0 : _ref$offset,
|
|
246
|
+
_ref$isEmit = _ref.isEmit,
|
|
247
|
+
isEmit = _ref$isEmit === void 0 ? false : _ref$isEmit,
|
|
248
|
+
_ref$movingStatus = _ref.movingStatus,
|
|
249
|
+
movingStatus = _ref$movingStatus === void 0 ? false : _ref$movingStatus;
|
|
250
|
+
if (childCount <= 1) return;
|
|
251
|
+
var targetActive = getActive(pace); // 父级容器偏移量
|
|
252
|
+
|
|
253
|
+
var targetOffset = getOffset(targetActive, offset); // 如果循环,调整开头结尾图片位置
|
|
254
|
+
|
|
255
|
+
if (props.loop) {
|
|
256
|
+
if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
|
|
257
|
+
var rightBound = targetOffset < minOffset;
|
|
258
|
+
childOffset[0] = rightBound ? trackSize : 0;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
|
|
262
|
+
var leftBound = targetOffset > 0;
|
|
263
|
+
childOffset[childCount - 1] = leftBound ? -trackSize : 0;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
setChildOffset(childOffset);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (isEmit && active !== targetActive) {
|
|
270
|
+
props.onChange && props.onChange((targetActive + childCount) % childCount);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
active = targetActive;
|
|
274
|
+
setActive(targetActive);
|
|
275
|
+
setOffset(targetOffset);
|
|
276
|
+
getStyle(targetOffset);
|
|
277
|
+
}; // 确定当前active 元素
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
var getActive = function getActive(pace) {
|
|
281
|
+
if (pace) {
|
|
282
|
+
var _active = active + pace;
|
|
283
|
+
|
|
284
|
+
if (props.loop) {
|
|
285
|
+
return range(_active, -1, childCount);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return range(_active, 0, childCount - 1);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return active;
|
|
292
|
+
}; // 计算位移
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
var getOffset = function getOffset(active) {
|
|
296
|
+
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
297
|
+
var currentPosition = active * Number(size);
|
|
298
|
+
|
|
299
|
+
if (!props.loop) {
|
|
300
|
+
currentPosition = Math.min(currentPosition, -minOffset);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
var targetOffset = offset - currentPosition;
|
|
304
|
+
|
|
305
|
+
if (!props.loop) {
|
|
306
|
+
targetOffset = range(targetOffset, minOffset, 0);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return targetOffset;
|
|
310
|
+
}; // 浏览器 帧 事件
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
var requestFrame = function requestFrame(fn) {
|
|
314
|
+
window.requestAnimationFrame.call(window, fn);
|
|
315
|
+
}; // 取值 方法
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
var range = function range(num, min, max) {
|
|
319
|
+
return Math.min(Math.max(num, min), max);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
var getDirection = function getDirection(x, y) {
|
|
323
|
+
if (x > y && x > DISTANCE) return 'horizontal';
|
|
324
|
+
if (y > x && y > DISTANCE) return 'vertical';
|
|
325
|
+
return '';
|
|
326
|
+
}; // 重置 全部位移信息
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
var touchReset = function touchReset() {
|
|
330
|
+
touch.startX = 0;
|
|
331
|
+
touch.startY = 0;
|
|
332
|
+
touch.deltaX = 0;
|
|
333
|
+
touch.deltaY = 0;
|
|
334
|
+
touch.offsetX = 0;
|
|
335
|
+
touch.offsetY = 0;
|
|
336
|
+
touch.delta = 0;
|
|
337
|
+
touch.stateDirection = '';
|
|
338
|
+
touch.touchTime = 0;
|
|
339
|
+
}; // 触摸事件开始
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
var touchStart = function touchStart(e) {
|
|
343
|
+
touchReset();
|
|
344
|
+
touch.startX = e.touches[0].clientX;
|
|
345
|
+
touch.startY = e.touches[0].clientY;
|
|
346
|
+
}; // 触摸事件移动
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
var touchMove = function touchMove(e) {
|
|
350
|
+
touch.deltaX = e.touches[0].clientX - touch.startX;
|
|
351
|
+
touch.deltaY = e.touches[0].clientY - touch.startY;
|
|
352
|
+
touch.offsetX = Math.abs(touch.deltaX);
|
|
353
|
+
touch.offsetY = Math.abs(touch.deltaY);
|
|
354
|
+
touch.delta = isVertical ? touch.deltaY : touch.deltaX;
|
|
355
|
+
|
|
356
|
+
if (!touch.stateDirection) {
|
|
357
|
+
touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
var b = cn('swiper');
|
|
362
|
+
var classes = classNames(b(''));
|
|
363
|
+
var contentClass = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(b('inner')), true), _defineProperty(_classNames, "".concat(b('vertical')), isVertical), _classNames));
|
|
364
|
+
|
|
365
|
+
var getStyle = function getStyle() {
|
|
366
|
+
var moveOffset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : offset;
|
|
367
|
+
var target = innerRef.current;
|
|
368
|
+
var _offset = 0;
|
|
369
|
+
|
|
370
|
+
if (!isCenter) {
|
|
371
|
+
_offset = moveOffset;
|
|
372
|
+
} else {
|
|
373
|
+
var _size = isVertical ? height : width;
|
|
374
|
+
|
|
375
|
+
var val = isVertical ? rect.height - _size : rect.width - _size;
|
|
376
|
+
_offset = moveOffset + (active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
target.style.transform = "translate3D".concat(!isVertical ? "(".concat(_offset, "px,0,0)") : "(0,".concat(_offset, "px,0)"));
|
|
380
|
+
target.style.transitionDuration = "".concat(_swiper.current.moving ? 0 : props.duration, "ms");
|
|
381
|
+
target.style[isVertical ? 'height' : 'width'] = "".concat(Number(size) * childCount, "px");
|
|
382
|
+
target.style[isVertical ? 'width' : 'height'] = "".concat(isVertical ? width : height, "px");
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
var onTouchStart = function onTouchStart(e) {
|
|
386
|
+
if (props.isPreventDefault) e.preventDefault();
|
|
387
|
+
if (props.isStopPropagation) e.stopPropagation();
|
|
388
|
+
if (!props.touchable) return;
|
|
389
|
+
touchStart(e);
|
|
390
|
+
touch.touchTime = Date.now();
|
|
391
|
+
stopAutoPlay();
|
|
392
|
+
resettPosition();
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
var onTouchMove = function onTouchMove(e) {
|
|
396
|
+
if (props.touchable && _swiper.current.moving) {
|
|
397
|
+
touchMove(e);
|
|
398
|
+
|
|
399
|
+
if (touch.stateDirection === props.direction) {
|
|
400
|
+
move({
|
|
401
|
+
offset: touch.delta
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
var onTouchEnd = function onTouchEnd(e) {
|
|
408
|
+
if (!props.touchable || !_swiper.current.moving) return;
|
|
409
|
+
var speed = touch.delta / (Date.now() - touch.touchTime);
|
|
410
|
+
var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > +(size / 2).toFixed(2);
|
|
411
|
+
var pace = 0;
|
|
412
|
+
_swiper.current.moving = false;
|
|
413
|
+
|
|
414
|
+
if (isShouldMove && touch.stateDirection === props.direction) {
|
|
415
|
+
var _offset2 = isVertical ? touch.offsetY : touch.offsetX;
|
|
416
|
+
|
|
417
|
+
if (props.loop) {
|
|
418
|
+
if (_offset2 > 0) {
|
|
419
|
+
pace = touch.delta > 0 ? -1 : 1;
|
|
420
|
+
} else {
|
|
421
|
+
pace = 0;
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
pace = -Math[touch.delta > 0 ? 'ceil' : 'floor'](touch.delta / size);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
move({
|
|
428
|
+
pace: pace,
|
|
429
|
+
isEmit: true
|
|
430
|
+
});
|
|
431
|
+
} else if (touch.delta) {
|
|
432
|
+
move({
|
|
433
|
+
pace: 0
|
|
434
|
+
});
|
|
435
|
+
} else {
|
|
436
|
+
getStyle();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
autoplay();
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
useEffect(function () {
|
|
443
|
+
_swiper.current.activePagination = (active + childCount) % childCount;
|
|
444
|
+
}, [active]);
|
|
445
|
+
|
|
446
|
+
var init = function init() {
|
|
447
|
+
var active = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : +propSwiper.initPage;
|
|
448
|
+
var rect = getRect(container === null || container === void 0 ? void 0 : container.current);
|
|
449
|
+
|
|
450
|
+
var _active = Math.max(Math.min(childCount - 1, active), 0);
|
|
451
|
+
|
|
452
|
+
var _width = propSwiper.width ? +propSwiper.width : rect.width;
|
|
453
|
+
|
|
454
|
+
var _height = propSwiper.height ? +propSwiper.height : rect.height;
|
|
455
|
+
|
|
456
|
+
size = isVertical ? _height : _width;
|
|
457
|
+
trackSize = childCount * Number(size);
|
|
458
|
+
var targetOffset = getOffset(_active);
|
|
459
|
+
_swiper.current.moving = true;
|
|
460
|
+
|
|
461
|
+
if (ready) {
|
|
462
|
+
_swiper.current.moving = false;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
setRect(rect);
|
|
466
|
+
setActive(_active);
|
|
467
|
+
setWidth(_width);
|
|
468
|
+
setHeight(_height);
|
|
469
|
+
setOffset(targetOffset);
|
|
470
|
+
setReady(true);
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
useEffect(function () {
|
|
474
|
+
if (ready) {
|
|
475
|
+
getStyle();
|
|
476
|
+
}
|
|
477
|
+
}, [isVertical, width, height, offset, ready]);
|
|
478
|
+
useEffect(function () {
|
|
479
|
+
if (ready) {
|
|
480
|
+
stopAutoPlay();
|
|
481
|
+
autoplay();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return function () {
|
|
485
|
+
setReady(false);
|
|
486
|
+
};
|
|
487
|
+
}, [ready]);
|
|
488
|
+
useEffect(function () {
|
|
489
|
+
stopAutoPlay();
|
|
490
|
+
autoplay();
|
|
491
|
+
}, [children]);
|
|
492
|
+
useEffect(function () {
|
|
493
|
+
init();
|
|
494
|
+
}, [propSwiper.initPage]);
|
|
495
|
+
useEffect(function () {
|
|
496
|
+
var target = container.current;
|
|
497
|
+
target.addEventListener('touchstart', onTouchStart, false);
|
|
498
|
+
target.addEventListener('touchmove', onTouchMove, false);
|
|
499
|
+
target.addEventListener('touchend', onTouchEnd, false);
|
|
500
|
+
return function () {
|
|
501
|
+
target.removeEventListener('touchstart', onTouchStart, false);
|
|
502
|
+
target.removeEventListener('touchmove', onTouchMove, false);
|
|
503
|
+
target.removeEventListener('touchend', onTouchEnd, false);
|
|
504
|
+
};
|
|
505
|
+
});
|
|
506
|
+
useEffect(function () {
|
|
507
|
+
return function () {
|
|
508
|
+
stopAutoPlay();
|
|
509
|
+
};
|
|
510
|
+
}, []);
|
|
511
|
+
|
|
512
|
+
var itemStyle = function itemStyle(index) {
|
|
513
|
+
var style = {};
|
|
514
|
+
|
|
515
|
+
var _direction = propSwiper.direction || direction;
|
|
516
|
+
|
|
517
|
+
var _size = size;
|
|
518
|
+
|
|
519
|
+
if (_size) {
|
|
520
|
+
style[_direction === 'horizontal' ? 'width' : 'height'] = "".concat(_size, "px");
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var offset = childOffset[index];
|
|
524
|
+
|
|
525
|
+
if (offset) {
|
|
526
|
+
style.transform = "translate3D".concat(_direction === 'horizontal' ? "(".concat(offset, "px,0,0)") : "(0,".concat(offset, "px,0)"));
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return style;
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
React__default.useImperativeHandle(ref, function () {
|
|
533
|
+
return {
|
|
534
|
+
to: to,
|
|
535
|
+
next: next,
|
|
536
|
+
prev: prev
|
|
537
|
+
};
|
|
538
|
+
});
|
|
539
|
+
return React__default.createElement(DataContext.Provider, {
|
|
540
|
+
value: parent
|
|
541
|
+
}, React__default.createElement("div", _objectSpread({
|
|
542
|
+
className: "".concat(classes, " ").concat(className),
|
|
543
|
+
ref: container
|
|
544
|
+
}, rest), React__default.createElement("div", {
|
|
545
|
+
className: contentClass,
|
|
546
|
+
ref: innerRef
|
|
547
|
+
}, React__default.Children.map(childs, function (child, index) {
|
|
548
|
+
return React__default.createElement("div", {
|
|
549
|
+
className: b('item-wrapper'),
|
|
550
|
+
style: itemStyle(index),
|
|
551
|
+
key: index
|
|
552
|
+
}, child);
|
|
553
|
+
})), propSwiper.paginationVisible && !('pageContent' in propSwiper) ? React__default.createElement("div", {
|
|
554
|
+
className: classNames((_classNames2 = {}, _defineProperty(_classNames2, "".concat(b('pagination')), true), _defineProperty(_classNames2, "".concat(b('pagination-vertical')), isVertical), _classNames2))
|
|
555
|
+
}, React__default.Children.map(childs, function (item, index) {
|
|
556
|
+
var _classNames3;
|
|
557
|
+
|
|
558
|
+
return React__default.createElement("i", {
|
|
559
|
+
style: (active + childCount) % childCount === index ? {
|
|
560
|
+
backgroundColor: propSwiper.paginationColor
|
|
561
|
+
} : undefined,
|
|
562
|
+
className: classNames((_classNames3 = {}, _defineProperty(_classNames3, "".concat(b('pagination-item')), true), _defineProperty(_classNames3, "active", (active + childCount) % childCount === index), _classNames3)),
|
|
563
|
+
key: index
|
|
564
|
+
});
|
|
565
|
+
})) : React__default.createElement("div", null, pageContent)));
|
|
566
|
+
});
|
|
567
|
+
Swiper.defaultProps = defaultProps$1;
|
|
568
|
+
Swiper.displayName = 'NutSwiper';
|
|
569
|
+
var defaultProps = {
|
|
570
|
+
images: [],
|
|
571
|
+
videos: [],
|
|
572
|
+
show: false,
|
|
573
|
+
autoplay: 3000,
|
|
574
|
+
initNo: 1,
|
|
575
|
+
contentClose: false,
|
|
576
|
+
paginationVisible: false,
|
|
577
|
+
paginationColor: '#fff',
|
|
578
|
+
onClose: function onClose() {}
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
var ImagePreview = function ImagePreview(props) {
|
|
582
|
+
var images = props.images,
|
|
583
|
+
videos = props.videos,
|
|
584
|
+
show = props.show,
|
|
585
|
+
initNo = props.initNo,
|
|
586
|
+
paginationColor = props.paginationColor,
|
|
587
|
+
paginationVisible = props.paginationVisible,
|
|
588
|
+
autoplay = props.autoplay,
|
|
589
|
+
contentClose = props.contentClose,
|
|
590
|
+
onClose = props.onClose;
|
|
591
|
+
var nutImagePreview = useRef(null);
|
|
592
|
+
|
|
593
|
+
var _useState17 = useState(false),
|
|
594
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
595
|
+
showPop = _useState18[0],
|
|
596
|
+
setShowPop = _useState18[1];
|
|
597
|
+
|
|
598
|
+
var _useState19 = useState(1),
|
|
599
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
600
|
+
active = _useState20[0],
|
|
601
|
+
setActive = _useState20[1];
|
|
602
|
+
|
|
603
|
+
var _useState21 = useState(1),
|
|
604
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
605
|
+
maxNo = _useState22[0],
|
|
606
|
+
setMaxNo = _useState22[1];
|
|
607
|
+
|
|
608
|
+
var _useState23 = useState({
|
|
609
|
+
scale: 1,
|
|
610
|
+
moveable: false
|
|
611
|
+
}),
|
|
612
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
613
|
+
store = _useState24[0],
|
|
614
|
+
setStore = _useState24[1];
|
|
615
|
+
|
|
616
|
+
var _useState25 = useState(0),
|
|
617
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
618
|
+
lastTouchEndTime = _useState26[0],
|
|
619
|
+
setLastTouchEndTime = _useState26[1]; // 用来辅助监听双击
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
var onTouchStart = function onTouchStart(event) {
|
|
623
|
+
var touches = event.touches;
|
|
624
|
+
var events = touches[0];
|
|
625
|
+
var events2 = touches[1]; // 如果已经放大,双击应变回原尺寸;如果是原尺寸,双击应放大
|
|
626
|
+
|
|
627
|
+
var curTouchTime = new Date().getTime();
|
|
628
|
+
|
|
629
|
+
if (curTouchTime - lastTouchEndTime < 300) {
|
|
630
|
+
var _store = store;
|
|
631
|
+
|
|
632
|
+
if (_store.scale > 1) {
|
|
633
|
+
_store.scale = 1;
|
|
634
|
+
} else if (_store.scale === 1) {
|
|
635
|
+
_store.scale = 2;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
scaleNow();
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
var store1 = store;
|
|
642
|
+
store1.moveable = true;
|
|
643
|
+
|
|
644
|
+
if (events2) {
|
|
645
|
+
// 如果开始两指操作,记录初始时刻两指间的距离
|
|
646
|
+
store1.oriDistance = getDistance({
|
|
647
|
+
x: events.pageX,
|
|
648
|
+
y: events.pageY
|
|
649
|
+
}, {
|
|
650
|
+
x: events2.pageX,
|
|
651
|
+
y: events2.pageY
|
|
652
|
+
});
|
|
653
|
+
} // 取到开始两指操作时的放大(缩小比例),store.scale 存储的是当前的放缩比(相对于标准大小 scale 为 1 的情况的放大缩小比)
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
store1.originScale = store1.scale || 1;
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
var onTouchMove = function onTouchMove(event) {
|
|
660
|
+
var touches = event.touches;
|
|
661
|
+
var events = touches[0];
|
|
662
|
+
var events2 = touches[1];
|
|
663
|
+
|
|
664
|
+
if (!store.moveable) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
var store1 = store; // 双指移动
|
|
669
|
+
|
|
670
|
+
if (events2) {
|
|
671
|
+
// 获得当前两点间的距离
|
|
672
|
+
var curDistance = getDistance({
|
|
673
|
+
x: events.pageX,
|
|
674
|
+
y: events.pageY
|
|
675
|
+
}, {
|
|
676
|
+
x: events2.pageX,
|
|
677
|
+
y: events2.pageY
|
|
678
|
+
});
|
|
679
|
+
/** 此处计算倍数,距离放大(缩小) k 倍则 scale 也 扩大(缩小) k 倍。距离放大(缩小)倍数 = 结束时两点距离 除以 开始时两点距离
|
|
680
|
+
* 注意此处的 scale 变化是基于 store.scale 的。
|
|
681
|
+
* store.scale 是一个暂存值,比如第一次放大 2 倍,则 store.scale 为 2。
|
|
682
|
+
* 再次两指触碰的时候,store.originScale 就为 store.scale 的值,基于此时的 store.scale 继续放大缩小。 * */
|
|
683
|
+
|
|
684
|
+
var curScale = curDistance / store1.oriDistance;
|
|
685
|
+
store1.scale = store1.originScale * curScale; // 最大放大 3 倍,缩小后松手要弹回原比例
|
|
686
|
+
|
|
687
|
+
if (store1.scale > 3) {
|
|
688
|
+
store1.scale = 3;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
scaleNow();
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
var onTouchEnd = function onTouchEnd() {
|
|
696
|
+
setLastTouchEndTime(new Date().getTime());
|
|
697
|
+
var store1 = store;
|
|
698
|
+
store1.moveable = false;
|
|
699
|
+
|
|
700
|
+
if (store1.scale < 1.1 && store1.scale > 1 || store1.scale < 1) {
|
|
701
|
+
store1.scale = 1;
|
|
702
|
+
scaleNow();
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
var init = function init() {
|
|
707
|
+
document.addEventListener('touchmove', onTouchMove);
|
|
708
|
+
document.addEventListener('touchend', onTouchEnd);
|
|
709
|
+
document.addEventListener('touchcancel', onTouchEnd);
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
useEffect(function () {
|
|
713
|
+
if (show !== undefined) {
|
|
714
|
+
setShowPop(show);
|
|
715
|
+
init();
|
|
716
|
+
}
|
|
717
|
+
}, [show]);
|
|
718
|
+
useEffect(function () {
|
|
719
|
+
if (initNo !== undefined) {
|
|
720
|
+
setActive(initNo);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
if (show !== undefined) {
|
|
724
|
+
setShowPop(show);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (images && videos) {
|
|
728
|
+
setMaxNo(images.length + videos.length);
|
|
729
|
+
}
|
|
730
|
+
}, []);
|
|
731
|
+
|
|
732
|
+
var scaleNow = function scaleNow() {
|
|
733
|
+
if (nutImagePreview.current) {
|
|
734
|
+
nutImagePreview.current.style.transform = "scale(".concat(store.scale, ")");
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
var onCloseInner = function onCloseInner() {
|
|
739
|
+
setShowPop(false);
|
|
740
|
+
setActive(1);
|
|
741
|
+
scaleNow();
|
|
742
|
+
onClose && onClose();
|
|
743
|
+
setStore(_objectSpread(_objectSpread({}, store), {}, {
|
|
744
|
+
scale: 1
|
|
745
|
+
}));
|
|
746
|
+
}; // 计算两个点的距离
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
var getDistance = function getDistance(first, second) {
|
|
750
|
+
// 计算两个点起始时刻的距离和终止时刻的距离,终止时刻距离变大了则放大,变小了则缩小
|
|
751
|
+
// 放大 k 倍则 scale 也 扩大 k 倍
|
|
752
|
+
return Math.hypot(Math.abs(second.x - first.x), Math.abs(second.y - first.y));
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
var slideChangeEnd = function slideChangeEnd(page) {
|
|
756
|
+
setActive(page + 1);
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
var closeOnImg = function closeOnImg() {
|
|
760
|
+
// 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
|
|
761
|
+
if (contentClose) {
|
|
762
|
+
onCloseInner();
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
return React__default.createElement(Popup, {
|
|
767
|
+
visible: showPop,
|
|
768
|
+
popClass: "custom-pop",
|
|
769
|
+
style: {
|
|
770
|
+
width: '100%'
|
|
771
|
+
},
|
|
772
|
+
onClick: onCloseInner
|
|
773
|
+
}, React__default.createElement("div", {
|
|
774
|
+
className: "nut-imagepreview",
|
|
775
|
+
ref: nutImagePreview,
|
|
776
|
+
onClick: closeOnImg,
|
|
777
|
+
onTouchStart: onTouchStart
|
|
778
|
+
}, React__default.createElement(Swiper, {
|
|
779
|
+
autoPlay: autoplay,
|
|
780
|
+
className: "nut-imagepreview-swiper",
|
|
781
|
+
loop: true,
|
|
782
|
+
isPreventDefault: false,
|
|
783
|
+
style: {
|
|
784
|
+
display: showPop ? 'block' : 'none'
|
|
785
|
+
},
|
|
786
|
+
direction: "horizontal",
|
|
787
|
+
onChange: slideChangeEnd,
|
|
788
|
+
initPage: initNo && (initNo > maxNo ? maxNo - 1 : initNo - 1),
|
|
789
|
+
paginationColor: paginationColor,
|
|
790
|
+
paginationVisible: paginationVisible
|
|
791
|
+
}, videos && videos.length > 0 && videos.map(function (item, index) {
|
|
792
|
+
return React__default.createElement(SwiperItem, {
|
|
793
|
+
key: index
|
|
794
|
+
}, React__default.createElement(Video, {
|
|
795
|
+
source: item.source,
|
|
796
|
+
options: item.options
|
|
797
|
+
}));
|
|
798
|
+
}), images && images.length > 0 && images.map(function (item, index) {
|
|
799
|
+
return React__default.createElement(SwiperItem, {
|
|
800
|
+
key: index
|
|
801
|
+
}, React__default.createElement("img", {
|
|
802
|
+
src: item.src,
|
|
803
|
+
alt: "",
|
|
804
|
+
className: "nut-imagepreview-img"
|
|
805
|
+
}));
|
|
806
|
+
}))), React__default.createElement("div", {
|
|
807
|
+
className: "nut-imagepreview-index"
|
|
808
|
+
}, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)));
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
ImagePreview.defaultProps = defaultProps;
|
|
812
|
+
ImagePreview.displayName = 'NutImagePreview';
|
|
813
|
+
export { ImagePreview as I };
|