@nutui/nutui-react-taro 3.0.3 → 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 (68) 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/sidebar/sidebar.js +3 -4
  28. package/dist/cjs/packages/tabbar/style/style.css +4 -9
  29. package/dist/cjs/packages/tabbaritem/style/style.css +4 -9
  30. package/dist/es/packages/badge/style/badge.scss +3 -8
  31. package/dist/es/packages/badge/style/style.css +4 -9
  32. package/dist/es/packages/badge/style/style.harmony.css +4 -9
  33. package/dist/es/packages/configprovider/types.d.ts +1 -1
  34. package/dist/es/packages/datepicker/style/style.css +0 -1
  35. package/dist/es/packages/datepickerview/style/style.css +0 -1
  36. package/dist/es/packages/empty/style/index.js +1 -0
  37. package/dist/es/packages/empty/style/style.css +389 -0
  38. package/dist/es/packages/fixednav/fixednav.js +4 -4
  39. package/dist/es/packages/fixednav/style/fixednav.scss +43 -39
  40. package/dist/es/packages/fixednav/style/style.css +47 -45
  41. package/dist/es/packages/fixednav/style/style.harmony.css +43 -36
  42. package/dist/es/packages/imagepreview/imagepreview.js +58 -91
  43. package/dist/es/packages/imagepreview/style/imagepreview.scss +2 -1
  44. package/dist/es/packages/imagepreview/style/style.css +2 -1
  45. package/dist/es/packages/imagepreview/style/style.harmony.css +2 -1
  46. package/dist/es/packages/inputnumber/inputnumber.js +2 -2
  47. package/dist/es/packages/picker/style/style.css +0 -1
  48. package/dist/es/packages/pickerview/pickerroller.js +75 -11
  49. package/dist/es/packages/pickerview/style/pickerview.scss +0 -1
  50. package/dist/es/packages/pickerview/style/style.css +0 -1
  51. package/dist/es/packages/resultpage/style/index.js +1 -0
  52. package/dist/es/packages/resultpage/style/style.css +389 -0
  53. package/dist/es/packages/sidebar/sidebar.js +3 -4
  54. package/dist/es/packages/tabbar/style/style.css +4 -9
  55. package/dist/es/packages/tabbaritem/style/style.css +4 -9
  56. package/dist/nutui.react.umd.js +132 -104
  57. package/dist/style.css +1 -1
  58. package/dist/style.scss +50 -50
  59. package/dist/styles/theme-dark.scss +2 -0
  60. package/dist/styles/theme-default.scss +2 -0
  61. package/dist/styles/themes/dark.css +1 -1
  62. package/dist/styles/themes/default.css +1 -1
  63. package/dist/styles/themes/jmapp.css +1 -1
  64. package/dist/styles/themes/jrkf.css +1 -1
  65. package/dist/styles/variables-jmapp.scss +1 -0
  66. package/dist/styles/variables-jrkf.scss +1 -0
  67. package/dist/styles/variables.scss +2 -1
  68. 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;
@@ -13,6 +13,7 @@ var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcar
13
13
  var _object_spread = require("@swc/helpers/_/_object_spread");
14
14
  var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
15
15
  var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
16
+ var _to_consumable_array = require("@swc/helpers/_/_to_consumable_array");
16
17
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
17
18
  var _taro = /*#__PURE__*/ _interop_require_default._(require("@tarojs/taro"));
18
19
  var _components = require("@tarojs/components");
@@ -37,7 +38,7 @@ var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typing
37
38
  closeIcon: false,
38
39
  closeIconPosition: 'top-right',
39
40
  showMenuByLongpress: false,
40
- onChange: function onChange(value) {},
41
+ onChange: function onChange() {},
41
42
  onClose: function onClose() {}
42
43
  });
43
44
  var ImagePreview = function ImagePreview(props) {
@@ -48,81 +49,59 @@ var ImagePreview = function ImagePreview(props) {
48
49
  value: value,
49
50
  defaultValue: defaultValue,
50
51
  finalValue: defaultValue,
51
- onChange: function onChange1(val) {
52
- onChange === null || onChange === void 0 ? void 0 : onChange(val);
53
- }
52
+ onChange: onChange
54
53
  }), 2), innerNo = _usePropsValue[0], setInnerNo = _usePropsValue[1];
55
54
  var _useState = (0, _sliced_to_array._)((0, _react.useState)(visible), 2), showPop = _useState[0], setShowPop = _useState[1];
56
55
  var _useState1 = (0, _sliced_to_array._)((0, _react.useState)(0), 2), active = _useState1[0], setActive = _useState1[1];
57
- var _useState2 = (0, _sliced_to_array._)((0, _react.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];
56
+ var _useState2 = (0, _sliced_to_array._)((0, _react.useState)(images.length + videos.length), 2), maxNo = _useState2[0], setMaxNo = _useState2[1];
58
57
  var _useState3 = (0, _sliced_to_array._)((0, _react.useState)({
59
58
  scale: 1,
60
- moveable: false
59
+ moveable: false,
60
+ oriDistance: 0,
61
+ originScale: 1
61
62
  }), 2), store = _useState3[0], setStore = _useState3[1];
62
- var _useState4 // 用来辅助监听双击
63
- = (0, _sliced_to_array._)((0, _react.useState)(0), 2), lastTouchEndTime = _useState4[0], setLastTouchEndTime = _useState4[1];
63
+ var lastTouchEndTime = (0, _react.useRef)(0) // 用来辅助监听双击
64
+ ;
64
65
  var onTouchStart = function onTouchStart(event) {
65
66
  var touches = event.touches;
66
67
  var events = touches[0];
67
68
  var events2 = touches[1];
68
69
  // 如果已经放大,双击应变回原尺寸;如果是原尺寸,双击应放大
69
- var curTouchTime = new Date().getTime();
70
- if (curTouchTime - lastTouchEndTime < 300) {
70
+ var curTouchTime = Date.now();
71
+ if (curTouchTime - lastTouchEndTime.current < 100) {
71
72
  var store1 = store;
72
- if (store1.scale > 1) {
73
- store1.scale = 1;
74
- } else if (store1.scale === 1) {
75
- store1.scale = 2;
76
- }
73
+ store1.scale = store1.scale === 1 ? 2 : 1;
77
74
  scaleNow();
78
75
  }
79
76
  var store11 = store;
80
77
  store11.moveable = true;
81
78
  if (events2) {
82
79
  // 如果开始两指操作,记录初始时刻两指间的距离
83
- store11.oriDistance = getDistance({
84
- x: events.pageX,
85
- y: events.pageY
86
- }, {
87
- x: events2.pageX,
88
- y: events2.pageY
89
- });
80
+ store11.oriDistance = getDistance(events, events2);
90
81
  }
91
82
  // 取到开始两指操作时的放大(缩小比例),store.scale 存储的是当前的放缩比(相对于标准大小 scale 为 1 的情况的放大缩小比)
92
- store11.originScale = store11.scale || 1;
83
+ store11.originScale = store11.scale;
93
84
  };
94
85
  var onTouchMove = function onTouchMove(event) {
86
+ if (!store.moveable) return;
95
87
  var touches = event.touches;
96
88
  var events = touches[0];
97
89
  var events2 = touches[1];
98
- if (!store.moveable) {
99
- return;
100
- }
101
90
  var store1 = store;
102
91
  // 双指移动
103
92
  if (events2) {
104
- // 获得当前两点间的距离
105
- var curDistance = getDistance({
106
- x: events.pageX,
107
- y: events.pageY
108
- }, {
109
- x: events2.pageX,
110
- y: events2.pageY
111
- });
93
+ var curDistance = getDistance(events, events2);
112
94
  /** 此处计算倍数,距离放大(缩小) k 倍则 scale 也 扩大(缩小) k 倍。距离放大(缩小)倍数 = 结束时两点距离 除以 开始时两点距离
113
95
  * 注意此处的 scale 变化是基于 store.scale 的。
114
96
  * store.scale 是一个暂存值,比如第一次放大 2 倍,则 store.scale 为 2。
115
97
  * 再次两指触碰的时候,store.originScale 就为 store.scale 的值,基于此时的 store.scale 继续放大缩小。 * */ var curScale = curDistance / store1.oriDistance;
116
- store1.scale = store1.originScale * curScale;
117
98
  // 最大放大 3 倍,缩小后松手要弹回原比例
118
- if (store1.scale > 3) {
119
- store1.scale = 3;
120
- }
99
+ store1.scale = Math.min(store1.originScale * curScale, 3);
121
100
  scaleNow();
122
101
  }
123
102
  };
124
103
  var onTouchEnd = function onTouchEnd() {
125
- setLastTouchEndTime(new Date().getTime());
104
+ lastTouchEndTime.current = Date.now();
126
105
  var store1 = store;
127
106
  store1.moveable = false;
128
107
  if (store1.scale < 1.1 && store1.scale > 1 || store1.scale < 1) {
@@ -137,6 +116,11 @@ var ImagePreview = function ImagePreview(props) {
137
116
  document.addEventListener('touchmove', onTouchMove);
138
117
  document.addEventListener('touchend', onTouchEnd);
139
118
  document.addEventListener('touchcancel', onTouchEnd);
119
+ return function() {
120
+ document.removeEventListener('touchcancel', onTouchEnd);
121
+ document.removeEventListener('touchmove', onTouchMove);
122
+ document.removeEventListener('touchend', onTouchEnd);
123
+ };
140
124
  };
141
125
  (0, _react.useEffect)(function() {
142
126
  setShowPop(visible);
@@ -154,22 +138,18 @@ var ImagePreview = function ImagePreview(props) {
154
138
  innerNo
155
139
  ]);
156
140
  (0, _react.useEffect)(function() {
157
- setMaxNo((images === null || images === void 0 ? void 0 : images.length) || 0 + ((videos === null || videos === void 0 ? void 0 : videos.length) || 0));
141
+ setMaxNo(images.length + videos.length);
158
142
  }, [
159
143
  images,
160
144
  videos
161
145
  ]);
162
146
  var scaleNow = function scaleNow() {
163
147
  if (ref.current) {
164
- ;
165
148
  ref.current.style.transform = "scale(".concat(store.scale, ")");
166
149
  }
167
150
  };
168
- // 计算两个点的距离
169
151
  var getDistance = function getDistance(first, second) {
170
- // 计算两个点起始时刻的距离和终止时刻的距离,终止时刻距离变大了则放大,变小了则缩小
171
- // 放大 k 倍则 scale 也 扩大 k 倍
172
- return Math.hypot(Math.abs(second.x - first.x), Math.abs(second.y - first.y));
152
+ return Math.hypot(Math.abs(second.pageX - first.pageX), Math.abs(second.pageY - first.pageY));
173
153
  };
174
154
  var slideChangeEnd = function slideChangeEnd(page) {
175
155
  setActive(page + 1);
@@ -180,30 +160,28 @@ var ImagePreview = function ImagePreview(props) {
180
160
  setShowPop(false);
181
161
  setActive(innerNo);
182
162
  scaleNow();
183
- onClose && onClose();
163
+ onClose === null || onClose === void 0 ? void 0 : onClose();
184
164
  setStore((0, _object_spread_props._)((0, _object_spread._)({}, store), {
185
165
  scale: 1
186
166
  }));
187
167
  };
188
168
  var closeOnImg = function closeOnImg(e) {
189
- // 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
190
169
  e.stopPropagation();
191
- if (closeOnContentClick) {
192
- onCloseInner(e);
193
- }
170
+ // 点击内容区域的图片是否可以关闭弹层(视频区域由于nut-video做了限制,无法关闭弹层)
171
+ if (closeOnContentClick) onCloseInner(e);
194
172
  };
195
173
  return /*#__PURE__*/ _react.default.createElement(_index.default, {
196
174
  visible: showPop,
197
175
  className: "".concat(classPrefix, "-pop"),
198
- style: {
199
- width: '100%'
200
- },
201
176
  onClick: onCloseInner
202
177
  }, /*#__PURE__*/ _react.default.createElement(_components.View, {
203
178
  className: (0, _classnames.default)(classPrefix, className),
204
179
  style: style,
205
180
  ref: ref,
206
- onTouchStart: onTouchStart
181
+ onTouchStart: onTouchStart,
182
+ onTouchMove: onTouchMove,
183
+ onTouchEnd: onTouchEnd,
184
+ onTouchCancel: onTouchEnd
207
185
  }, /*#__PURE__*/ _react.default.createElement(_index2.default, {
208
186
  autoPlay: autoPlay,
209
187
  className: "".concat(classPrefix, "-swiper"),
@@ -221,57 +199,46 @@ var ImagePreview = function ImagePreview(props) {
221
199
  },
222
200
  defaultValue: innerNo && (innerNo > maxNo ? maxNo - 1 : innerNo - 1),
223
201
  indicator: indicator
224
- }, (videos !== null && videos !== void 0 ? videos : []).map(function(item) {
202
+ }, (0, _to_consumable_array._)(videos.map(function(item) {
225
203
  return {
226
204
  type: 'video',
227
205
  data: item
228
206
  };
229
- }).concat((images !== null && images !== void 0 ? images : []).map(function(item) {
207
+ })).concat((0, _to_consumable_array._)(images.map(function(item) {
230
208
  return {
231
209
  type: 'image',
232
210
  data: item
233
211
  };
234
- })).sort(function(a, b) {
212
+ }))).sort(function(a, b) {
235
213
  var _a_data, _b_data;
236
214
  var _a_data_index, _b_data_index;
237
215
  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);
238
216
  }).map(function(item, index) {
239
- if (item.type === 'video') {
240
- var _item_data = item.data, source = _item_data.source, options = _item_data.options;
241
- return /*#__PURE__*/ _react.default.createElement(_index3.default, {
242
- key: index,
243
- className: "nut-imagepreview-swiper-item"
244
- }, /*#__PURE__*/ _react.default.createElement(_components.Video, {
245
- src: source.src,
246
- onClick: closeOnImg,
247
- controls: options.controls,
248
- autoplay: false,
249
- loop: false,
250
- muted: options.muted
251
- }));
252
- }
253
- if (item.type === 'image') {
254
- var src = item.data.src;
255
- return /*#__PURE__*/ _react.default.createElement(_index3.default, {
256
- key: index,
257
- className: "nut-imagepreview-swiper-item"
258
- }, /*#__PURE__*/ _react.default.createElement(_index1.default, (0, _object_spread._)({
259
- src: src,
260
- mode: "widthFix",
261
- onClick: closeOnImg,
262
- style: {
263
- width: '100%'
264
- }
265
- }, _taro.default.getEnv() !== 'WEB' && {
266
- showMenuByLongpress: showMenuByLongpress
267
- })));
268
- }
269
- return null;
270
- }))), pagination ? /*#__PURE__*/ _react.default.createElement(_components.View, {
217
+ return /*#__PURE__*/ _react.default.createElement(_index3.default, {
218
+ key: index,
219
+ className: "nut-imagepreview-swiper-item"
220
+ }, item.type === 'video' ? /*#__PURE__*/ _react.default.createElement(_components.Video, {
221
+ src: item.data.source.src,
222
+ onClick: closeOnImg,
223
+ controls: item.data.options.controls,
224
+ autoplay: false,
225
+ loop: false,
226
+ muted: item.data.options.muted
227
+ }) : /*#__PURE__*/ _react.default.createElement(_index1.default, (0, _object_spread._)({
228
+ src: item.data.src,
229
+ mode: "widthFix",
230
+ onClick: closeOnImg,
231
+ style: {
232
+ width: '100%'
233
+ }
234
+ }, _taro.default.getEnv() !== 'WEB' && {
235
+ showMenuByLongpress: showMenuByLongpress
236
+ })));
237
+ }))), pagination && /*#__PURE__*/ _react.default.createElement(_components.View, {
271
238
  className: "".concat(classPrefix, "-index")
272
- }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)) : null, closeIcon !== false ? /*#__PURE__*/ _react.default.createElement(_components.View, {
239
+ }, active, "/", maxNo), closeIcon !== false && /*#__PURE__*/ _react.default.createElement(_components.View, {
273
240
  className: "".concat(classPrefix, "-close ").concat(closeIconPosition),
274
241
  onClick: onCloseInner
275
- }, closeIcon === true ? /*#__PURE__*/ _react.default.createElement(_iconsreacttaro.Close, null) : closeIcon) : null);
242
+ }, closeIcon === true ? /*#__PURE__*/ _react.default.createElement(_iconsreacttaro.Close, null) : closeIcon));
276
243
  };
277
244
  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 {