@nutui/nutui-react-taro 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/packages/badge/style/badge.scss +3 -8
  3. package/dist/cjs/packages/badge/style/style.css +4 -9
  4. package/dist/cjs/packages/badge/style/style.harmony.css +4 -9
  5. package/dist/cjs/packages/configprovider/types.d.ts +1 -1
  6. package/dist/cjs/packages/datepicker/style/style.css +0 -1
  7. package/dist/cjs/packages/datepickerview/style/style.css +0 -1
  8. package/dist/cjs/packages/empty/style/index.js +1 -0
  9. package/dist/cjs/packages/empty/style/style.css +389 -0
  10. package/dist/cjs/packages/fixednav/fixednav.js +3 -3
  11. package/dist/cjs/packages/fixednav/style/fixednav.scss +43 -39
  12. package/dist/cjs/packages/fixednav/style/style.css +47 -45
  13. package/dist/cjs/packages/fixednav/style/style.harmony.css +43 -36
  14. package/dist/cjs/packages/imagepreview/imagepreview.js +58 -91
  15. package/dist/cjs/packages/imagepreview/style/imagepreview.scss +2 -1
  16. package/dist/cjs/packages/imagepreview/style/style.css +2 -1
  17. package/dist/cjs/packages/imagepreview/style/style.harmony.css +2 -1
  18. package/dist/cjs/packages/inputnumber/inputnumber.js +2 -2
  19. package/dist/cjs/packages/nutui.react.d.ts +1 -0
  20. package/dist/cjs/packages/nutui.react.js +1 -0
  21. package/dist/cjs/packages/picker/style/style.css +0 -1
  22. package/dist/cjs/packages/pickerview/pickerroller.js +76 -11
  23. package/dist/cjs/packages/pickerview/style/pickerview.scss +0 -1
  24. package/dist/cjs/packages/pickerview/style/style.css +0 -1
  25. package/dist/cjs/packages/resultpage/style/index.js +1 -0
  26. package/dist/cjs/packages/resultpage/style/style.css +389 -0
  27. package/dist/cjs/packages/tabbar/style/style.css +4 -9
  28. package/dist/cjs/packages/tabbaritem/style/style.css +4 -9
  29. package/dist/es/packages/badge/style/badge.scss +3 -8
  30. package/dist/es/packages/badge/style/style.css +4 -9
  31. package/dist/es/packages/badge/style/style.harmony.css +4 -9
  32. package/dist/es/packages/configprovider/types.d.ts +1 -1
  33. package/dist/es/packages/datepicker/style/style.css +0 -1
  34. package/dist/es/packages/datepickerview/style/style.css +0 -1
  35. package/dist/es/packages/empty/style/index.js +1 -0
  36. package/dist/es/packages/empty/style/style.css +389 -0
  37. package/dist/es/packages/fixednav/fixednav.js +4 -4
  38. package/dist/es/packages/fixednav/style/fixednav.scss +43 -39
  39. package/dist/es/packages/fixednav/style/style.css +47 -45
  40. package/dist/es/packages/fixednav/style/style.harmony.css +43 -36
  41. package/dist/es/packages/imagepreview/imagepreview.js +58 -91
  42. package/dist/es/packages/imagepreview/style/imagepreview.scss +2 -1
  43. package/dist/es/packages/imagepreview/style/style.css +2 -1
  44. package/dist/es/packages/imagepreview/style/style.harmony.css +2 -1
  45. package/dist/es/packages/inputnumber/inputnumber.js +2 -2
  46. package/dist/es/packages/picker/style/style.css +0 -1
  47. package/dist/es/packages/pickerview/pickerroller.js +75 -11
  48. package/dist/es/packages/pickerview/style/pickerview.scss +0 -1
  49. package/dist/es/packages/pickerview/style/style.css +0 -1
  50. package/dist/es/packages/resultpage/style/index.js +1 -0
  51. package/dist/es/packages/resultpage/style/style.css +389 -0
  52. package/dist/es/packages/tabbar/style/style.css +4 -9
  53. package/dist/es/packages/tabbaritem/style/style.css +4 -9
  54. package/dist/nutui.react.umd.js +129 -100
  55. package/dist/style.css +1 -1
  56. package/dist/style.scss +48 -48
  57. package/dist/styles/theme-dark.scss +2 -0
  58. package/dist/styles/theme-default.scss +2 -0
  59. package/dist/styles/themes/dark.css +1 -1
  60. package/dist/styles/themes/default.css +1 -1
  61. package/dist/styles/themes/jmapp.css +1 -1
  62. package/dist/styles/themes/jrkf.css +1 -1
  63. package/dist/styles/variables-jmapp.scss +1 -0
  64. package/dist/styles/variables-jrkf.scss +1 -0
  65. package/dist/styles/variables.scss +2 -1
  66. package/package.json +1 -1
@@ -60,6 +60,8 @@
60
60
  .nut-badge {
61
61
  position: relative;
62
62
  display: inline-flex;
63
+ vertical-align: middle;
64
+ box-sizing: content-box;
63
65
  width: auto;
64
66
  }
65
67
  .nut-badge-icon {
@@ -92,13 +94,12 @@
92
94
  }
93
95
  .nut-badge-sup {
94
96
  display: inline-flex;
95
- justify-content: center;
96
- height: var(--nutui-badge-height, 14px);
97
+ text-align: center;
97
98
  min-width: var(--nutui-badge-min-width, 6px);
98
99
  padding: var(--nutui-badge-padding, 1px 4px);
99
100
  box-sizing: border-box;
100
101
  color: var(--nutui-badge-color, #ffffff);
101
- font-size: var(--nutui-badge-font-size, var(--nutui-font-size-xxs, 10px));
102
+ font-size: var(--nutui-badge-font-size, var(--nutui-font-size-xxxs, 9px));
102
103
  line-height: 12px;
103
104
  white-space: nowrap;
104
105
  font-weight: normal;
@@ -108,12 +109,6 @@
108
109
  }
109
110
  .nut-badge-number {
110
111
  font-family: "JD";
111
- /* #ifdef harmony */
112
- line-height: 12px;
113
- /* #endif */
114
- /* #ifndef harmony */
115
- line-height: 13px;
116
- /* #endif */
117
112
  }
118
113
  .nut-badge-one {
119
114
  height: var(--nutui-badge-height, 14px);
@@ -159,7 +154,6 @@
159
154
  z-index: var(--nutui-fixednav-index, 900);
160
155
  display: inline-block;
161
156
  height: 50px;
162
- right: 0;
163
157
  }
164
158
  .nut-fixednav.active .nut-fixednav-btn .nut-icon {
165
159
  transform: rotate(180deg);
@@ -167,18 +161,16 @@
167
161
  .nut-fixednav.active .nut-fixednav-list {
168
162
  transform: translateX(0%) !important;
169
163
  }
170
- .nut-fixednav.active.left .nut-icon {
171
- transform: rotate(0deg) !important;
164
+ .nut-fixednav.active.nut-fixednav-left .nut-icon {
165
+ transform: rotate(0deg);
172
166
  }
173
167
  .nut-fixednav-btn {
174
168
  box-sizing: border-box;
175
169
  position: absolute;
176
- right: 0;
177
170
  z-index: var(--nutui-fixednav-index, 900);
178
171
  width: 70px;
179
172
  height: 100%;
180
173
  background: var(--nutui-fixednav-button-background, var(--nutui-color-primary, #ff0f23));
181
- border-radius: 45px 0px 0px 45px;
182
174
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.2);
183
175
  display: flex;
184
176
  align-items: center;
@@ -192,15 +184,10 @@
192
184
  flex-shrink: 0;
193
185
  }
194
186
  .nut-fixednav-btn .nut-icon {
195
- margin-right: 5px;
196
- transition: all 0.3s;
197
- transform: rotate(0deg);
198
187
  transition: all 0.3s;
199
188
  }
200
189
  .nut-fixednav-list {
201
190
  position: absolute;
202
- right: 0;
203
- transform: translateX(100%);
204
191
  transition: all 0.5s;
205
192
  z-index: var(--nutui-fixednav-index, 900);
206
193
  flex-shrink: 0;
@@ -208,10 +195,7 @@
208
195
  background: var(--nutui-fixednav-background-color, #ffffff);
209
196
  display: flex;
210
197
  justify-content: space-between;
211
- border-radius: 25px 0px 0px 25px;
212
198
  box-shadow: 2px 2px 8px 0px rgba(0, 0, 0, 0.2);
213
- padding-left: 20px;
214
- padding-right: 80px;
215
199
  }
216
200
  .nut-fixednav-list-item {
217
201
  position: relative;
@@ -225,45 +209,63 @@
225
209
  flex-shrink: 0;
226
210
  color: var(--nutui-fixednav-color, #1a1a1a);
227
211
  }
228
- .nut-fixednav-list-item img {
212
+ .nut-fixednav-list-item .nut-fixednav-list-text {
213
+ font-size: 10px;
214
+ }
215
+ .nut-fixednav-list-image {
229
216
  width: 20px;
230
217
  height: 20px;
231
218
  margin-bottom: 2px;
232
219
  }
233
- .nut-fixednav-list-item .nut-fixednav-list-text {
234
- font-size: 10px;
220
+ .nut-fixednav-right {
221
+ right: 0;
235
222
  }
236
- .nut-fixednav.left {
237
- right: auto;
223
+ .nut-fixednav-right .nut-fixednav-btn {
224
+ right: 0;
225
+ border-radius: 45px 0px 0px 45px;
226
+ }
227
+ .nut-fixednav-right .nut-fixednav-btn .nut-icon {
228
+ margin-right: 5px;
229
+ transform: rotate(0deg);
230
+ }
231
+ .nut-fixednav-right .nut-fixednav-list {
232
+ right: 0;
233
+ transform: translateX(100%);
234
+ border-radius: 25px 0px 0px 25px;
235
+ padding-left: 20px;
236
+ padding-right: 80px;
237
+ }
238
+ .nut-fixednav-left {
238
239
  left: 0;
239
240
  }
240
- .nut-fixednav.left .nut-fixednav-btn {
241
+ .nut-fixednav-left .nut-fixednav-btn {
241
242
  flex-direction: row-reverse;
242
- right: auto;
243
243
  left: 0;
244
244
  border-radius: 0 45px 45px 0;
245
245
  }
246
- .nut-fixednav.left .nut-fixednav-btn .nut-icon {
247
- transform: rotate(180deg);
248
- margin-right: 0px;
246
+ .nut-fixednav-left .nut-fixednav-btn .nut-icon {
249
247
  margin-left: 5px;
248
+ transform: rotate(180deg);
250
249
  }
251
- .nut-fixednav.left .nut-fixednav-list {
250
+ .nut-fixednav-left .nut-fixednav-list {
252
251
  transform: translateX(-100%);
253
- right: auto;
252
+ left: 0;
254
253
  border-radius: 0px 25px 25px 0px;
255
254
  padding-left: 80px;
256
255
  padding-right: 20px;
257
- margin: 0;
258
256
  }
259
257
 
260
- [dir=rtl] .nut-fixednav,
261
- .nut-rtl .nut-fixednav {
258
+ [dir=rtl] .nut-fixednav-right,
259
+ .nut-rtl .nut-fixednav-right {
262
260
  right: auto;
263
261
  left: 0;
264
262
  }
265
263
  [dir=rtl] .nut-fixednav.active .nut-icon,
266
264
  .nut-rtl .nut-fixednav.active .nut-icon {
265
+ transform: rotate(0deg);
266
+ }
267
+ [dir=rtl] .nut-fixednav.active.nut-fixednav-left .nut-icon,
268
+ .nut-rtl .nut-fixednav.active.nut-fixednav-left .nut-icon {
267
269
  transform: rotate(-180deg);
268
270
  }
269
271
  [dir=rtl] .nut-fixednav-btn,
@@ -293,25 +295,25 @@
293
295
  right: auto;
294
296
  left: 0;
295
297
  }
296
- [dir=rtl] .nut-fixednav.left,
297
- .nut-rtl .nut-fixednav.left {
298
+ [dir=rtl] .nut-fixednav-left,
299
+ .nut-rtl .nut-fixednav-left {
298
300
  left: auto;
299
301
  right: 0;
300
302
  }
301
- [dir=rtl] .nut-fixednav.left .nut-fixednav-btn,
302
- .nut-rtl .nut-fixednav.left .nut-fixednav-btn {
303
+ [dir=rtl] .nut-fixednav-left .nut-fixednav-btn,
304
+ .nut-rtl .nut-fixednav-left .nut-fixednav-btn {
303
305
  left: auto;
304
306
  right: 0;
305
307
  border-radius: 45px 0 0 45px;
306
308
  }
307
- [dir=rtl] .nut-fixednav.left .nut-fixednav-btn .nut-icon,
308
- .nut-rtl .nut-fixednav.left .nut-fixednav-btn .nut-icon {
309
+ [dir=rtl] .nut-fixednav-left .nut-fixednav-btn .nut-icon,
310
+ .nut-rtl .nut-fixednav-left .nut-fixednav-btn .nut-icon {
309
311
  transform: rotate(0deg);
310
312
  margin-right: 5px;
311
313
  margin-left: 0px;
312
314
  }
313
- [dir=rtl] .nut-fixednav.left .nut-fixednav-list,
314
- .nut-rtl .nut-fixednav.left .nut-fixednav-list {
315
+ [dir=rtl] .nut-fixednav-left .nut-fixednav-list,
316
+ .nut-rtl .nut-fixednav-left .nut-fixednav-list {
315
317
  transform: translateX(100%);
316
318
  right: auto;
317
319
  left: auto;
@@ -7,7 +7,6 @@
7
7
  z-index: 900;
8
8
  display: inline-block;
9
9
  height: 50px;
10
- right: 0;
11
10
  }
12
11
  .nut-fixednav.active .nut-fixednav-btn .nut-icon {
13
12
  transform: rotate(180deg);
@@ -15,18 +14,16 @@
15
14
  .nut-fixednav.active .nut-fixednav-list {
16
15
  transform: translateX(0%) !important;
17
16
  }
18
- .nut-fixednav.active.left .nut-icon {
19
- transform: rotate(0deg) !important;
17
+ .nut-fixednav.active.nut-fixednav-left .nut-icon {
18
+ transform: rotate(0deg);
20
19
  }
21
20
  .nut-fixednav-btn {
22
21
  box-sizing: border-box;
23
22
  position: absolute;
24
- right: 0;
25
23
  z-index: 900;
26
24
  width: 70px;
27
25
  height: 100%;
28
26
  background: #ff0f23;
29
- border-radius: 45px 0px 0px 45px;
30
27
  box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.2);
31
28
  display: flex;
32
29
  align-items: center;
@@ -40,15 +37,10 @@
40
37
  flex-shrink: 0;
41
38
  }
42
39
  .nut-fixednav-btn .nut-icon {
43
- margin-right: 5px;
44
- transition: all 0.3s;
45
- transform: rotate(0deg);
46
40
  transition: all 0.3s;
47
41
  }
48
42
  .nut-fixednav-list {
49
43
  position: absolute;
50
- right: 0;
51
- transform: translateX(100%);
52
44
  transition: all 0.5s;
53
45
  z-index: 900;
54
46
  flex-shrink: 0;
@@ -56,10 +48,7 @@
56
48
  background: #ffffff;
57
49
  display: flex;
58
50
  justify-content: space-between;
59
- border-radius: 25px 0px 0px 25px;
60
51
  box-shadow: 2px 2px 8px 0px rgba(0, 0, 0, 0.2);
61
- padding-left: 20px;
62
- padding-right: 80px;
63
52
  }
64
53
  .nut-fixednav-list-item {
65
54
  position: relative;
@@ -73,45 +62,63 @@
73
62
  flex-shrink: 0;
74
63
  color: #1a1a1a;
75
64
  }
76
- .nut-fixednav-list-item img {
65
+ .nut-fixednav-list-item .nut-fixednav-list-text {
66
+ font-size: 10px;
67
+ }
68
+ .nut-fixednav-list-image {
77
69
  width: 20px;
78
70
  height: 20px;
79
71
  margin-bottom: 2px;
80
72
  }
81
- .nut-fixednav-list-item .nut-fixednav-list-text {
82
- font-size: 10px;
73
+ .nut-fixednav-right {
74
+ right: 0;
83
75
  }
84
- .nut-fixednav.left {
85
- right: auto;
76
+ .nut-fixednav-right .nut-fixednav-btn {
77
+ right: 0;
78
+ border-radius: 45px 0px 0px 45px;
79
+ }
80
+ .nut-fixednav-right .nut-fixednav-btn .nut-icon {
81
+ margin-right: 5px;
82
+ transform: rotate(0deg);
83
+ }
84
+ .nut-fixednav-right .nut-fixednav-list {
85
+ right: 0;
86
+ transform: translateX(100%);
87
+ border-radius: 25px 0px 0px 25px;
88
+ padding-left: 20px;
89
+ padding-right: 80px;
90
+ }
91
+ .nut-fixednav-left {
86
92
  left: 0;
87
93
  }
88
- .nut-fixednav.left .nut-fixednav-btn {
94
+ .nut-fixednav-left .nut-fixednav-btn {
89
95
  flex-direction: row-reverse;
90
- right: auto;
91
96
  left: 0;
92
97
  border-radius: 0 45px 45px 0;
93
98
  }
94
- .nut-fixednav.left .nut-fixednav-btn .nut-icon {
95
- transform: rotate(180deg);
96
- margin-right: 0px;
99
+ .nut-fixednav-left .nut-fixednav-btn .nut-icon {
97
100
  margin-left: 5px;
101
+ transform: rotate(180deg);
98
102
  }
99
- .nut-fixednav.left .nut-fixednav-list {
103
+ .nut-fixednav-left .nut-fixednav-list {
100
104
  transform: translateX(-100%);
101
- right: auto;
105
+ left: 0;
102
106
  border-radius: 0px 25px 25px 0px;
103
107
  padding-left: 80px;
104
108
  padding-right: 20px;
105
- margin: 0;
106
109
  }
107
110
 
108
- [dir=rtl] .nut-fixednav,
109
- .nut-rtl .nut-fixednav {
111
+ [dir=rtl] .nut-fixednav-right,
112
+ .nut-rtl .nut-fixednav-right {
110
113
  right: auto;
111
114
  left: 0;
112
115
  }
113
116
  [dir=rtl] .nut-fixednav.active .nut-icon,
114
117
  .nut-rtl .nut-fixednav.active .nut-icon {
118
+ transform: rotate(0deg);
119
+ }
120
+ [dir=rtl] .nut-fixednav.active.nut-fixednav-left .nut-icon,
121
+ .nut-rtl .nut-fixednav.active.nut-fixednav-left .nut-icon {
115
122
  transform: rotate(-180deg);
116
123
  }
117
124
  [dir=rtl] .nut-fixednav-btn,
@@ -141,25 +148,25 @@
141
148
  right: auto;
142
149
  left: 0;
143
150
  }
144
- [dir=rtl] .nut-fixednav.left,
145
- .nut-rtl .nut-fixednav.left {
151
+ [dir=rtl] .nut-fixednav-left,
152
+ .nut-rtl .nut-fixednav-left {
146
153
  left: auto;
147
154
  right: 0;
148
155
  }
149
- [dir=rtl] .nut-fixednav.left .nut-fixednav-btn,
150
- .nut-rtl .nut-fixednav.left .nut-fixednav-btn {
156
+ [dir=rtl] .nut-fixednav-left .nut-fixednav-btn,
157
+ .nut-rtl .nut-fixednav-left .nut-fixednav-btn {
151
158
  left: auto;
152
159
  right: 0;
153
160
  border-radius: 45px 0 0 45px;
154
161
  }
155
- [dir=rtl] .nut-fixednav.left .nut-fixednav-btn .nut-icon,
156
- .nut-rtl .nut-fixednav.left .nut-fixednav-btn .nut-icon {
162
+ [dir=rtl] .nut-fixednav-left .nut-fixednav-btn .nut-icon,
163
+ .nut-rtl .nut-fixednav-left .nut-fixednav-btn .nut-icon {
157
164
  transform: rotate(0deg);
158
165
  margin-right: 5px;
159
166
  margin-left: 0px;
160
167
  }
161
- [dir=rtl] .nut-fixednav.left .nut-fixednav-list,
162
- .nut-rtl .nut-fixednav.left .nut-fixednav-list {
168
+ [dir=rtl] .nut-fixednav-left .nut-fixednav-list,
169
+ .nut-rtl .nut-fixednav-left .nut-fixednav-list {
163
170
  transform: translateX(100%);
164
171
  right: auto;
165
172
  left: auto;
@@ -1,6 +1,7 @@
1
1
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
3
3
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
5
  import React, { useEffect, useRef, useState } from "react";
5
6
  import Taro from "@tarojs/taro";
6
7
  import { Video as TaroVideo, View } from "@tarojs/components";
@@ -25,7 +26,7 @@ var defaultProps = _object_spread_props(_object_spread({}, ComponentDefaults), {
25
26
  closeIcon: false,
26
27
  closeIconPosition: 'top-right',
27
28
  showMenuByLongpress: false,
28
- onChange: function(value) {},
29
+ onChange: function() {},
29
30
  onClose: function() {}
30
31
  });
31
32
  export var ImagePreview = function(props) {
@@ -36,81 +37,59 @@ export var ImagePreview = function(props) {
36
37
  value: value,
37
38
  defaultValue: defaultValue,
38
39
  finalValue: defaultValue,
39
- onChange: function(val) {
40
- onChange === null || onChange === void 0 ? void 0 : onChange(val);
41
- }
40
+ onChange: onChange
42
41
  }), 2), innerNo = _usePropsValue[0], setInnerNo = _usePropsValue[1];
43
42
  var _useState = _sliced_to_array(useState(visible), 2), showPop = _useState[0], setShowPop = _useState[1];
44
43
  var _useState1 = _sliced_to_array(useState(0), 2), active = _useState1[0], setActive = _useState1[1];
45
- var _useState2 = _sliced_to_array(useState((images === null || images === void 0 ? void 0 : images.length) || 0 + ((videos === null || videos === void 0 ? void 0 : videos.length) || 0)), 2), maxNo = _useState2[0], setMaxNo = _useState2[1];
44
+ var _useState2 = _sliced_to_array(useState(images.length + videos.length), 2), maxNo = _useState2[0], setMaxNo = _useState2[1];
46
45
  var _useState3 = _sliced_to_array(useState({
47
46
  scale: 1,
48
- moveable: false
47
+ moveable: false,
48
+ oriDistance: 0,
49
+ originScale: 1
49
50
  }), 2), store = _useState3[0], setStore = _useState3[1];
50
- var _useState4 // 用来辅助监听双击
51
- = _sliced_to_array(useState(0), 2), lastTouchEndTime = _useState4[0], setLastTouchEndTime = _useState4[1];
51
+ var lastTouchEndTime = useRef(0) // 用来辅助监听双击
52
+ ;
52
53
  var onTouchStart = function(event) {
53
54
  var touches = event.touches;
54
55
  var events = touches[0];
55
56
  var events2 = touches[1];
56
57
  // 如果已经放大,双击应变回原尺寸;如果是原尺寸,双击应放大
57
- var curTouchTime = new Date().getTime();
58
- if (curTouchTime - lastTouchEndTime < 300) {
58
+ var curTouchTime = Date.now();
59
+ if (curTouchTime - lastTouchEndTime.current < 100) {
59
60
  var store1 = store;
60
- if (store1.scale > 1) {
61
- store1.scale = 1;
62
- } else if (store1.scale === 1) {
63
- store1.scale = 2;
64
- }
61
+ store1.scale = store1.scale === 1 ? 2 : 1;
65
62
  scaleNow();
66
63
  }
67
64
  var store11 = store;
68
65
  store11.moveable = true;
69
66
  if (events2) {
70
67
  // 如果开始两指操作,记录初始时刻两指间的距离
71
- store11.oriDistance = getDistance({
72
- x: events.pageX,
73
- y: events.pageY
74
- }, {
75
- x: events2.pageX,
76
- y: events2.pageY
77
- });
68
+ store11.oriDistance = getDistance(events, events2);
78
69
  }
79
70
  // 取到开始两指操作时的放大(缩小比例),store.scale 存储的是当前的放缩比(相对于标准大小 scale 为 1 的情况的放大缩小比)
80
- store11.originScale = store11.scale || 1;
71
+ store11.originScale = store11.scale;
81
72
  };
82
73
  var onTouchMove = function(event) {
74
+ if (!store.moveable) return;
83
75
  var touches = event.touches;
84
76
  var events = touches[0];
85
77
  var events2 = touches[1];
86
- if (!store.moveable) {
87
- return;
88
- }
89
78
  var store1 = store;
90
79
  // 双指移动
91
80
  if (events2) {
92
- // 获得当前两点间的距离
93
- var curDistance = getDistance({
94
- x: events.pageX,
95
- y: events.pageY
96
- }, {
97
- x: events2.pageX,
98
- y: events2.pageY
99
- });
81
+ var curDistance = getDistance(events, events2);
100
82
  /** 此处计算倍数,距离放大(缩小) k 倍则 scale 也 扩大(缩小) k 倍。距离放大(缩小)倍数 = 结束时两点距离 除以 开始时两点距离
101
83
  * 注意此处的 scale 变化是基于 store.scale 的。
102
84
  * store.scale 是一个暂存值,比如第一次放大 2 倍,则 store.scale 为 2。
103
85
  * 再次两指触碰的时候,store.originScale 就为 store.scale 的值,基于此时的 store.scale 继续放大缩小。 * */ var curScale = curDistance / store1.oriDistance;
104
- store1.scale = store1.originScale * curScale;
105
86
  // 最大放大 3 倍,缩小后松手要弹回原比例
106
- if (store1.scale > 3) {
107
- store1.scale = 3;
108
- }
87
+ store1.scale = Math.min(store1.originScale * curScale, 3);
109
88
  scaleNow();
110
89
  }
111
90
  };
112
91
  var onTouchEnd = function() {
113
- setLastTouchEndTime(new Date().getTime());
92
+ lastTouchEndTime.current = Date.now();
114
93
  var store1 = store;
115
94
  store1.moveable = false;
116
95
  if (store1.scale < 1.1 && store1.scale > 1 || store1.scale < 1) {
@@ -125,6 +104,11 @@ export var ImagePreview = function(props) {
125
104
  document.addEventListener('touchmove', onTouchMove);
126
105
  document.addEventListener('touchend', onTouchEnd);
127
106
  document.addEventListener('touchcancel', onTouchEnd);
107
+ return function() {
108
+ document.removeEventListener('touchcancel', onTouchEnd);
109
+ document.removeEventListener('touchmove', onTouchMove);
110
+ document.removeEventListener('touchend', onTouchEnd);
111
+ };
128
112
  };
129
113
  useEffect(function() {
130
114
  setShowPop(visible);
@@ -142,22 +126,18 @@ export var ImagePreview = function(props) {
142
126
  innerNo
143
127
  ]);
144
128
  useEffect(function() {
145
- setMaxNo((images === null || images === void 0 ? void 0 : images.length) || 0 + ((videos === null || videos === void 0 ? void 0 : videos.length) || 0));
129
+ setMaxNo(images.length + videos.length);
146
130
  }, [
147
131
  images,
148
132
  videos
149
133
  ]);
150
134
  var scaleNow = function() {
151
135
  if (ref.current) {
152
- ;
153
136
  ref.current.style.transform = "scale(".concat(store.scale, ")");
154
137
  }
155
138
  };
156
- // 计算两个点的距离
157
139
  var getDistance = function(first, second) {
158
- // 计算两个点起始时刻的距离和终止时刻的距离,终止时刻距离变大了则放大,变小了则缩小
159
- // 放大 k 倍则 scale 也 扩大 k 倍
160
- return Math.hypot(Math.abs(second.x - first.x), Math.abs(second.y - first.y));
140
+ return Math.hypot(Math.abs(second.pageX - first.pageX), Math.abs(second.pageY - first.pageY));
161
141
  };
162
142
  var slideChangeEnd = function(page) {
163
143
  setActive(page + 1);
@@ -168,30 +148,28 @@ export var ImagePreview = function(props) {
168
148
  setShowPop(false);
169
149
  setActive(innerNo);
170
150
  scaleNow();
171
- onClose && onClose();
151
+ onClose === null || onClose === void 0 ? void 0 : onClose();
172
152
  setStore(_object_spread_props(_object_spread({}, store), {
173
153
  scale: 1
174
154
  }));
175
155
  };
176
156
  var closeOnImg = function(e) {
177
- // 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
178
157
  e.stopPropagation();
179
- if (closeOnContentClick) {
180
- onCloseInner(e);
181
- }
158
+ // 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
159
+ if (closeOnContentClick) onCloseInner(e);
182
160
  };
183
161
  return /*#__PURE__*/ React.createElement(Popup, {
184
162
  visible: showPop,
185
163
  className: "".concat(classPrefix, "-pop"),
186
- style: {
187
- width: '100%'
188
- },
189
164
  onClick: onCloseInner
190
165
  }, /*#__PURE__*/ React.createElement(View, {
191
166
  className: classNames(classPrefix, className),
192
167
  style: style,
193
168
  ref: ref,
194
- onTouchStart: onTouchStart
169
+ onTouchStart: onTouchStart,
170
+ onTouchMove: onTouchMove,
171
+ onTouchEnd: onTouchEnd,
172
+ onTouchCancel: onTouchEnd
195
173
  }, /*#__PURE__*/ React.createElement(Swiper, {
196
174
  autoPlay: autoPlay,
197
175
  className: "".concat(classPrefix, "-swiper"),
@@ -209,57 +187,46 @@ export var ImagePreview = function(props) {
209
187
  },
210
188
  defaultValue: innerNo && (innerNo > maxNo ? maxNo - 1 : innerNo - 1),
211
189
  indicator: indicator
212
- }, (videos !== null && videos !== void 0 ? videos : []).map(function(item) {
190
+ }, _to_consumable_array(videos.map(function(item) {
213
191
  return {
214
192
  type: 'video',
215
193
  data: item
216
194
  };
217
- }).concat((images !== null && images !== void 0 ? images : []).map(function(item) {
195
+ })).concat(_to_consumable_array(images.map(function(item) {
218
196
  return {
219
197
  type: 'image',
220
198
  data: item
221
199
  };
222
- })).sort(function(a, b) {
200
+ }))).sort(function(a, b) {
223
201
  var _a_data, _b_data;
224
202
  var _a_data_index, _b_data_index;
225
203
  return ((_a_data_index = (_a_data = a.data) === null || _a_data === void 0 ? void 0 : _a_data.index) !== null && _a_data_index !== void 0 ? _a_data_index : 0) - ((_b_data_index = (_b_data = b.data) === null || _b_data === void 0 ? void 0 : _b_data.index) !== null && _b_data_index !== void 0 ? _b_data_index : 0);
226
204
  }).map(function(item, index) {
227
- if (item.type === 'video') {
228
- var _item_data = item.data, source = _item_data.source, options = _item_data.options;
229
- return /*#__PURE__*/ React.createElement(SwiperItem, {
230
- key: index,
231
- className: "nut-imagepreview-swiper-item"
232
- }, /*#__PURE__*/ React.createElement(TaroVideo, {
233
- src: source.src,
234
- onClick: closeOnImg,
235
- controls: options.controls,
236
- autoplay: false,
237
- loop: false,
238
- muted: options.muted
239
- }));
240
- }
241
- if (item.type === 'image') {
242
- var src = item.data.src;
243
- return /*#__PURE__*/ React.createElement(SwiperItem, {
244
- key: index,
245
- className: "nut-imagepreview-swiper-item"
246
- }, /*#__PURE__*/ React.createElement(Image, _object_spread({
247
- src: src,
248
- mode: "widthFix",
249
- onClick: closeOnImg,
250
- style: {
251
- width: '100%'
252
- }
253
- }, Taro.getEnv() !== 'WEB' && {
254
- showMenuByLongpress: showMenuByLongpress
255
- })));
256
- }
257
- return null;
258
- }))), pagination ? /*#__PURE__*/ React.createElement(View, {
205
+ return /*#__PURE__*/ React.createElement(SwiperItem, {
206
+ key: index,
207
+ className: "nut-imagepreview-swiper-item"
208
+ }, item.type === 'video' ? /*#__PURE__*/ React.createElement(TaroVideo, {
209
+ src: item.data.source.src,
210
+ onClick: closeOnImg,
211
+ controls: item.data.options.controls,
212
+ autoplay: false,
213
+ loop: false,
214
+ muted: item.data.options.muted
215
+ }) : /*#__PURE__*/ React.createElement(Image, _object_spread({
216
+ src: item.data.src,
217
+ mode: "widthFix",
218
+ onClick: closeOnImg,
219
+ style: {
220
+ width: '100%'
221
+ }
222
+ }, Taro.getEnv() !== 'WEB' && {
223
+ showMenuByLongpress: showMenuByLongpress
224
+ })));
225
+ }))), pagination && /*#__PURE__*/ React.createElement(View, {
259
226
  className: "".concat(classPrefix, "-index")
260
- }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)) : null, closeIcon !== false ? /*#__PURE__*/ React.createElement(View, {
227
+ }, active, "/", maxNo), closeIcon !== false && /*#__PURE__*/ React.createElement(View, {
261
228
  className: "".concat(classPrefix, "-close ").concat(closeIconPosition),
262
229
  onClick: onCloseInner
263
- }, closeIcon === true ? /*#__PURE__*/ React.createElement(Close, null) : closeIcon) : null);
230
+ }, closeIcon === true ? /*#__PURE__*/ React.createElement(Close, null) : closeIcon));
264
231
  };
265
232
  ImagePreview.displayName = 'NutImagePreview';
@@ -57,11 +57,12 @@
57
57
  }
58
58
 
59
59
  &-pop {
60
+ width: 100%;
60
61
  height: 100%;
62
+ max-width: 100% !important;
61
63
  background: transparent !important;
62
64
  display: flex;
63
65
  align-items: center;
64
- width: 100%;
65
66
  }
66
67
 
67
68
  &-swiper {
@@ -697,11 +697,12 @@
697
697
  text-align: center;
698
698
  }
699
699
  .nut-imagepreview-pop {
700
+ width: 100%;
700
701
  height: 100%;
702
+ max-width: 100% !important;
701
703
  background: transparent !important;
702
704
  display: flex;
703
705
  align-items: center;
704
- width: 100%;
705
706
  }
706
707
  .nut-imagepreview-swiper .nut-imagepreview-swiper-item,
707
708
  .nut-imagepreview-swiper .nut-swiper-item {
@@ -53,11 +53,12 @@
53
53
  text-align: center;
54
54
  }
55
55
  .nut-imagepreview-pop {
56
+ width: 100%;
56
57
  height: 100%;
58
+ max-width: 100% !important;
57
59
  background: transparent !important;
58
60
  display: flex;
59
61
  align-items: center;
60
- width: 100%;
61
62
  }
62
63
  .nut-imagepreview-swiper .nut-imagepreview-swiper-item,
63
64
  .nut-imagepreview-swiper .nut-swiper-item {