@conecli/cone-render 0.10.1-shop3.6 → 0.10.1-shop3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/index.h5.ts +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -0
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/jumpExtMapUtil.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from 'react';
|
|
2
1
|
isH5AndJdShopView,
|
|
3
2
|
isAndroidDevice,
|
|
4
3
|
isJdAndAndroidDevice,
|
|
5
4
|
isJdAndIosDevice,
|
|
6
5
|
isIosDevice,
|
|
7
6
|
isJdApp,
|
|
8
7
|
isWxMin,
|
|
9
8
|
isH5AndJdShopViewH5Scroll,
|
|
10
9
|
isH5AndJdShopH5CustomScrollView,
|
|
11
10
|
isH5,
|
|
12
11
|
isAppClassifyPage,
|
|
13
12
|
lodashThrottle,
|
|
14
13
|
START: 'start',
|
|
15
14
|
MOVE: 'move',
|
|
16
15
|
END: 'end',
|
|
17
16
|
const {
|
|
18
17
|
scrollX,
|
|
19
18
|
children,
|
|
20
19
|
style = {},
|
|
21
20
|
iosNeedDisableVertical,
|
|
22
21
|
dispatchTouchMove,
|
|
23
22
|
className,
|
|
24
23
|
...otherProps
|
|
25
24
|
} = props;
|
|
26
25
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null;
|
|
27
26
|
const needShowHighVersion =
|
|
28
27
|
isH5AndJdShopViewH5Scroll &&
|
|
29
28
|
!(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
|
|
30
29
|
const mLastClientPosRef = useRef({
|
|
31
30
|
mLastClientX: 0,
|
|
32
31
|
mLastClientY: 0,
|
|
33
32
|
});
|
|
34
33
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
|
|
35
34
|
|
|
36
35
|
const touchstartEventBubbleFunc = (e) => {
|
|
37
36
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
38
37
|
if (!isH5SwiperCustomEle) {
|
|
39
38
|
const hasCustomEle = e
|
|
40
39
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
41
40
|
: false;
|
|
42
41
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
43
42
|
window.JdAndroid && window.JdAndroid.requestEvent(false);
|
|
44
43
|
}
|
|
45
44
|
!hasCustomEle &&
|
|
46
45
|
rootEleNode &&
|
|
47
46
|
rootEleNode.classList.contains('over-hidden') &&
|
|
48
47
|
rootEleNode.classList.remove('over-hidden');
|
|
49
48
|
}
|
|
50
49
|
};
|
|
51
50
|
const touchstartEventCaptureFunc = (e) => {
|
|
52
51
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
|
|
53
52
|
rootEleNode &&
|
|
54
53
|
rootEleNode.classList.contains('over-hidden') &&
|
|
55
54
|
rootEleNode.classList.remove('over-hidden');
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
57
|
useEffect(() => {
|
|
59
58
|
isJdApp &&
|
|
60
59
|
!window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
61
60
|
nativePageGetScaledTouchSlop((res) => {
|
|
62
61
|
console.log('获取安卓系统滑动阈值', res);
|
|
63
62
|
window.JDJshopViewInfo.androidTouchSlop = res;
|
|
64
63
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true;
|
|
65
64
|
});
|
|
66
65
|
if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
|
|
67
66
|
global?.removeJdAndroidRquestEventForTouchStart &&
|
|
68
67
|
global.removeJdAndroidRquestEventForTouchStart();
|
|
69
68
|
rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
70
69
|
|
|
71
70
|
rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
72
71
|
rootEleAddEventListenerState = true;
|
|
73
72
|
console.log('customScrollView 初始化document监听完成');
|
|
74
73
|
}
|
|
75
74
|
return () => {
|
|
76
75
|
if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
|
|
77
76
|
console.log('customScrollView document监听取消完成');
|
|
78
77
|
rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
79
78
|
rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
81
|
}, []);
|
|
83
82
|
|
|
84
83
|
const androidDeviceStopNativeScrollEvent = (touchType) => {
|
|
85
84
|
isJdApp &&
|
|
86
85
|
isAndroidDevice &&
|
|
87
86
|
window?.JdAndroid &&
|
|
88
87
|
window?.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
89
88
|
};
|
|
90
89
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
91
90
|
sendIosState && iosDeviceSendRouter(touchType);
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
const iosDeviceSendRouter = (state: string) => {
|
|
95
94
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
96
95
|
method: 'callRouterModuleWithParams',
|
|
97
96
|
params: {
|
|
98
97
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
99
98
|
routerParam: {
|
|
100
99
|
slideDirection: 'horizontal',
|
|
101
100
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
102
101
|
state,
|
|
103
102
|
},
|
|
104
103
|
callBackId: new Date().getTime(),
|
|
105
104
|
},
|
|
106
105
|
});
|
|
107
106
|
};
|
|
108
107
|
const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
|
|
109
108
|
if (isJdApp) {
|
|
110
109
|
isIosDevice &&
|
|
111
110
|
!isAppClassifyPage &&
|
|
112
111
|
iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
|
|
113
112
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
|
|
114
113
|
}
|
|
115
114
|
};
|
|
116
115
|
|
|
117
116
|
const GetSlideAngle = (dx, dy) => {
|
|
118
117
|
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
119
118
|
};
|
|
120
119
|
|
|
121
120
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
122
121
|
const dy = startY - endY;
|
|
123
122
|
const dx = endX - startX;
|
|
124
123
|
let result = 0;
|
|
125
124
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
126
125
|
return result;
|
|
127
126
|
}
|
|
128
127
|
const angle = GetSlideAngle(dx, dy);
|
|
129
128
|
if (angle >= -45 && angle < 45) {
|
|
130
129
|
result = 4;
|
|
131
130
|
} else if (angle >= 45 && angle < 135) {
|
|
132
131
|
result = 1;
|
|
133
132
|
} else if (angle >= -135 && angle < -45) {
|
|
134
133
|
result = 2;
|
|
135
134
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
136
135
|
result = 3;
|
|
137
136
|
}
|
|
138
137
|
return result;
|
|
139
138
|
};
|
|
140
139
|
const changeTouchStart = (e) => {
|
|
141
140
|
if (isJdApp) {
|
|
142
141
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
|
|
143
142
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
144
143
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
145
144
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
146
145
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
|
|
147
146
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
149
|
};
|
|
151
150
|
const changeTouchEnd = (e) => {
|
|
152
151
|
stopNativeScrollEvent(e, TouchType.END);
|
|
153
152
|
mLastClientPosRef.current.mLastClientX = 0;
|
|
154
153
|
mLastClientPosRef.current.mLastClientY = 0;
|
|
155
154
|
};
|
|
156
155
|
const triggerIosTouchMove = () => {
|
|
157
156
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
|
|
158
157
|
};
|
|
159
158
|
|
|
160
159
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
|
|
161
160
|
|
|
162
161
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
163
162
|
const direction = GetSlideDirection(
|
|
164
163
|
mLastClientPosRef.current.mLastClientX,
|
|
165
164
|
mLastClientPosRef.current.mLastClientY,
|
|
166
165
|
touchEvent.clientX,
|
|
167
166
|
touchEvent.clientY,
|
|
168
167
|
);
|
|
169
168
|
if (direction === 1 || direction === 2) {
|
|
170
169
|
rootEleNode &&
|
|
171
170
|
rootEleNode.classList.contains('over-hidden') &&
|
|
172
171
|
rootEleNode.classList.remove('over-hidden');
|
|
173
172
|
}
|
|
174
173
|
};
|
|
175
174
|
const changeTouchMove = (e) => {
|
|
176
175
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
177
176
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
178
177
|
const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
|
|
179
178
|
2,
|
|
180
179
|
);
|
|
181
180
|
const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
|
|
182
181
|
2,
|
|
183
182
|
);
|
|
184
183
|
if (isJdApp) {
|
|
185
184
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
186
185
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
|
|
187
186
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
188
187
|
console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
|
|
189
188
|
stopNativeScrollEvent(e, TouchType.END);
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
|
|
193
192
|
}
|
|
194
193
|
if (!dispatchTouchMove) {
|
|
195
194
|
return;
|
|
196
195
|
}
|
|
197
196
|
const parentNode = e.target?.parentNode;
|
|
198
197
|
if (!parentNode) {
|
|
199
198
|
return;
|
|
200
199
|
}
|
|
201
200
|
const event = new TouchEvent('touchmove', e);
|
|
202
201
|
parentNode.dispatchEvent(event);
|
|
203
202
|
};
|
|
204
203
|
if (scrollX && isJdApp && !isIgnorePreventNative) {
|
|
205
204
|
return (
|
|
206
205
|
<ScrollView
|
|
207
206
|
scrollX
|
|
208
207
|
onTouchStart={changeTouchStart}
|
|
209
208
|
onTouchEnd={changeTouchEnd}
|
|
210
209
|
onTouchCancel={changeTouchEnd}
|
|
211
210
|
onTouchMove={changeTouchMove}
|
|
212
211
|
enhanced
|
|
213
212
|
showScrollbar={false}
|
|
214
213
|
style={style}
|
|
215
214
|
className={classNames(
|
|
216
215
|
className,
|
|
217
216
|
{
|
|
218
217
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
219
218
|
},
|
|
220
219
|
'J_customScroll',
|
|
221
220
|
)}
|
|
222
221
|
{...otherProps}
|
|
223
222
|
>
|
|
224
223
|
{children}
|
|
225
224
|
</ScrollView>
|
|
226
225
|
);
|
|
227
226
|
} else {
|
|
228
227
|
return (
|
|
229
228
|
<ScrollView
|
|
230
229
|
scrollX
|
|
231
230
|
enhanced
|
|
232
231
|
showScrollbar={false}
|
|
233
232
|
{...otherProps}
|
|
234
233
|
className={classNames(
|
|
235
234
|
className,
|
|
236
235
|
{
|
|
237
236
|
[customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
|
|
238
237
|
isIosDevice && isWxMin && scrollX && style['borderRadius'],
|
|
239
238
|
},
|
|
240
239
|
{
|
|
241
240
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
242
241
|
},
|
|
243
242
|
{
|
|
244
243
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
|
|
245
244
|
},
|
|
246
245
|
)}
|
|
247
246
|
style={style}
|
|
248
247
|
>
|
|
249
248
|
{children}
|
|
250
249
|
</ScrollView>
|
|
251
250
|
);
|
|
252
251
|
}
|
|
253
252
|
style: {},
|
|
254
253
|
scrollX: false,
|
|
255
254
|
scrollY: false,
|
|
256
255
|
scrollWithAnimation: true,
|
|
257
256
|
iosNeedDisableVertical: false,
|
|
258
257
|
className: null,
|
|
259
258
|
dispatchTouchMove: true,
|
|
259
|
+
import React, { useRef, useEffect } from 'react';
|
|
260
260
|
isH5AndJdShopView,
|
|
261
261
|
isAndroidDevice,
|
|
262
262
|
isJdAndAndroidDevice,
|
|
263
263
|
isJdAndIosDevice,
|
|
264
264
|
isIosDevice,
|
|
265
265
|
isJdApp,
|
|
266
266
|
isWxMin,
|
|
267
267
|
isH5AndJdShopViewH5Scroll,
|
|
268
268
|
isH5AndJdShopH5CustomScrollView,
|
|
269
269
|
isH5,
|
|
270
270
|
isAppClassifyPage,
|
|
271
271
|
lodashThrottle,
|
|
272
272
|
START: 'start',
|
|
273
273
|
MOVE: 'move',
|
|
274
274
|
END: 'end',
|
|
275
275
|
const {
|
|
276
276
|
scrollX,
|
|
277
277
|
children,
|
|
278
278
|
style = {},
|
|
279
279
|
iosNeedDisableVertical,
|
|
280
280
|
dispatchTouchMove,
|
|
281
281
|
className,
|
|
282
282
|
...otherProps
|
|
283
283
|
} = props;
|
|
284
284
|
const rootEleNode = isH5 && document ? document.querySelector('body') : null;
|
|
285
285
|
const needShowHighVersion =
|
|
286
286
|
isH5AndJdShopViewH5Scroll &&
|
|
287
287
|
!(global.info.queryInfo?.downgraded && global.info.queryInfo.downgraded === 'true');
|
|
288
288
|
const mLastClientPosRef = useRef({
|
|
289
289
|
mLastClientX: 0,
|
|
290
290
|
mLastClientY: 0,
|
|
291
291
|
});
|
|
292
292
|
const isJdAndH5ScrollState = needShowHighVersion || isH5AndJdShopH5CustomScrollView;
|
|
293
293
|
|
|
294
294
|
const touchstartEventBubbleFunc = (e) => {
|
|
295
295
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
296
296
|
if (!isH5SwiperCustomEle) {
|
|
297
297
|
const hasCustomEle = e
|
|
298
298
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
299
299
|
: false;
|
|
300
300
|
if (isJdAndAndroidDevice && !hasCustomEle) {
|
|
301
301
|
window?.JdAndroid &&
|
|
302
302
|
window?.JdAndroid?.requestEvent &&
|
|
303
303
|
window.JdAndroid.requestEvent(false);
|
|
304
304
|
}
|
|
305
305
|
!hasCustomEle &&
|
|
306
306
|
rootEleNode &&
|
|
307
307
|
rootEleNode.classList.contains('over-hidden') &&
|
|
308
308
|
rootEleNode.classList.remove('over-hidden');
|
|
309
309
|
console.log(
|
|
310
310
|
'customScrollView所在页面document touch start事件是否有J_customScroll元素',
|
|
311
311
|
hasCustomEle,
|
|
312
312
|
'根元素是否有over-hidden',
|
|
313
313
|
rootEleNode.classList,
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
const touchstartEventCaptureFunc = (e) => {
|
|
318
318
|
if (e && !e?.target?.closest('.J_h5SwiperCustom') && !e?.target?.closest('.J_customLayout')) {
|
|
319
319
|
rootEleNode &&
|
|
320
320
|
rootEleNode.classList.contains('over-hidden') &&
|
|
321
321
|
rootEleNode.classList.remove('over-hidden');
|
|
322
322
|
console.log(
|
|
323
323
|
'customScrollView所在页面document touch start事件捕获阶段移除根元素是否有over-hidden',
|
|
324
324
|
rootEleNode.classList,
|
|
325
325
|
);
|
|
326
326
|
}
|
|
327
327
|
};
|
|
328
328
|
useEffect(() => {
|
|
329
329
|
isJdApp &&
|
|
330
330
|
!window.JDJshopViewInfo.getAndroidTouchSlopState &&
|
|
331
331
|
nativePageGetScaledTouchSlop((res) => {
|
|
332
332
|
console.log('获取安卓系统滑动阈值', res);
|
|
333
333
|
window.JDJshopViewInfo.androidTouchSlop = res;
|
|
334
334
|
window.JDJshopViewInfo.getAndroidTouchSlopState = true;
|
|
335
335
|
});
|
|
336
336
|
if (isJdAndH5ScrollState && rootEleNode && !rootEleAddEventListenerState) {
|
|
337
337
|
global?.removeJdAndroidRquestEventForTouchStart &&
|
|
338
338
|
global.removeJdAndroidRquestEventForTouchStart();
|
|
339
339
|
rootEleNode.addEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
340
340
|
|
|
341
341
|
rootEleNode.addEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
342
342
|
rootEleAddEventListenerState = true;
|
|
343
343
|
console.log('customScrollView 初始化document监听完成');
|
|
344
344
|
}
|
|
345
345
|
return () => {
|
|
346
346
|
if (isJdAndH5ScrollState && rootEleNode && rootEleAddEventListenerState) {
|
|
347
347
|
console.log('customScrollView document监听取消完成');
|
|
348
348
|
rootEleNode.removeEventListener('touchstart', touchstartEventBubbleFunc, false);
|
|
349
349
|
rootEleNode.removeEventListener('touchstart', touchstartEventCaptureFunc, true);
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
}, []);
|
|
353
353
|
|
|
354
354
|
const androidDeviceStopNativeScrollEvent = (touchType) => {
|
|
355
355
|
isJdApp &&
|
|
356
356
|
isAndroidDevice &&
|
|
357
357
|
window?.JdAndroid &&
|
|
358
358
|
window?.JdAndroid?.requestEvent &&
|
|
359
359
|
window.JdAndroid.requestEvent(touchType === TouchType.START);
|
|
360
360
|
console.log('触发window?.JdAndroid.requestEvent', touchType === TouchType.START, touchType);
|
|
361
361
|
};
|
|
362
362
|
const iosDeviceStopNativeScrollEvent = (e, touchType, sendIosState = true) => {
|
|
363
363
|
sendIosState && iosDeviceSendRouter(touchType);
|
|
364
364
|
};
|
|
365
365
|
|
|
366
366
|
const iosDeviceSendRouter = (state: string) => {
|
|
367
367
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage?.({
|
|
368
368
|
method: 'callRouterModuleWithParams',
|
|
369
369
|
params: {
|
|
370
370
|
routerURL: 'router://JDShopModule/processShoph5SlideState',
|
|
371
371
|
routerParam: {
|
|
372
372
|
slideDirection: 'horizontal',
|
|
373
373
|
needDisableVertical: `${iosNeedDisableVertical}`,
|
|
374
374
|
state,
|
|
375
375
|
},
|
|
376
376
|
callBackId: new Date().getTime(),
|
|
377
377
|
},
|
|
378
378
|
});
|
|
379
379
|
};
|
|
380
380
|
const stopNativeScrollEvent = (e: Event, touchType, sendIosState = true) => {
|
|
381
381
|
if (isJdApp) {
|
|
382
382
|
isIosDevice &&
|
|
383
383
|
!isAppClassifyPage &&
|
|
384
384
|
iosDeviceStopNativeScrollEvent(e, touchType, sendIosState);
|
|
385
385
|
isAndroidDevice && androidDeviceStopNativeScrollEvent(touchType);
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
|
|
389
389
|
const GetSlideAngle = (dx, dy) => {
|
|
390
390
|
return (Math.atan2(dy, dx) * 180) / Math.PI;
|
|
391
391
|
};
|
|
392
392
|
|
|
393
393
|
const GetSlideDirection = (startX, startY, endX, endY) => {
|
|
394
394
|
const dy = startY - endY;
|
|
395
395
|
const dx = endX - startX;
|
|
396
396
|
let result = 0;
|
|
397
397
|
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) {
|
|
398
398
|
return result;
|
|
399
399
|
}
|
|
400
400
|
const angle = GetSlideAngle(dx, dy);
|
|
401
401
|
if (angle >= -45 && angle < 45) {
|
|
402
402
|
result = 4;
|
|
403
403
|
} else if (angle >= 45 && angle < 135) {
|
|
404
404
|
result = 1;
|
|
405
405
|
} else if (angle >= -135 && angle < -45) {
|
|
406
406
|
result = 2;
|
|
407
407
|
} else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
|
|
408
408
|
result = 3;
|
|
409
409
|
}
|
|
410
410
|
return result;
|
|
411
411
|
};
|
|
412
412
|
const changeTouchStart = (e) => {
|
|
413
413
|
if (isJdApp) {
|
|
414
414
|
stopNativeScrollEvent(e, TouchType.START, !iosNeedDisableVertical);
|
|
415
415
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
416
416
|
isJdAndH5ScrollState && rootEleNode && rootEleNode.classList.add('over-hidden');
|
|
417
417
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
418
418
|
mLastClientPosRef.current.mLastClientX = touchEvent.clientX;
|
|
419
419
|
mLastClientPosRef.current.mLastClientY = touchEvent.clientY;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
const changeTouchEnd = (e) => {
|
|
424
424
|
stopNativeScrollEvent(e, TouchType.END);
|
|
425
425
|
mLastClientPosRef.current.mLastClientX = 0;
|
|
426
426
|
mLastClientPosRef.current.mLastClientY = 0;
|
|
427
427
|
};
|
|
428
428
|
const triggerIosTouchMove = () => {
|
|
429
429
|
isJdAndIosDevice && iosDeviceStopNativeScrollEvent(null, TouchType.START, true);
|
|
430
430
|
};
|
|
431
431
|
|
|
432
432
|
const lodashThrottleTriggerIosTouchMove = lodashThrottle(triggerIosTouchMove, 500);
|
|
433
433
|
|
|
434
434
|
const recoverRootEleVerticalScroll = (touchEvent) => {
|
|
435
435
|
const direction = GetSlideDirection(
|
|
436
436
|
mLastClientPosRef.current.mLastClientX,
|
|
437
437
|
mLastClientPosRef.current.mLastClientY,
|
|
438
438
|
touchEvent.clientX,
|
|
439
439
|
touchEvent.clientY,
|
|
440
440
|
);
|
|
441
441
|
if (direction === 1 || direction === 2) {
|
|
442
442
|
rootEleNode &&
|
|
443
443
|
rootEleNode.classList.contains('over-hidden') &&
|
|
444
444
|
rootEleNode.classList.remove('over-hidden');
|
|
445
445
|
}
|
|
446
446
|
};
|
|
447
447
|
const changeTouchMove = (e) => {
|
|
448
448
|
if (isH5AndJdShopView || isH5AndJdShopH5CustomScrollView) {
|
|
449
449
|
const touchEvent = e?.originalEvent?.targetTouches[0] || e?.targetTouches[0];
|
|
450
450
|
const xDiff = Math.abs(touchEvent.clientX - mLastClientPosRef.current.mLastClientX).toFixed(
|
|
451
451
|
2,
|
|
452
452
|
);
|
|
453
453
|
const yDiff = Math.abs(touchEvent.clientY - mLastClientPosRef.current.mLastClientY).toFixed(
|
|
454
454
|
2,
|
|
455
455
|
);
|
|
456
456
|
if (isJdApp) {
|
|
457
457
|
if (xDiff >= window.JDJshopViewInfo.androidTouchSlop) {
|
|
458
458
|
iosNeedDisableVertical && isJdApp && lodashThrottleTriggerIosTouchMove();
|
|
459
459
|
} else if (yDiff > window.JDJshopViewInfo.androidTouchSlop) {
|
|
460
460
|
console.log('纵向滚动触发', yDiff, touchEvent, window.JDJshopViewInfo.androidTouchSlop);
|
|
461
461
|
stopNativeScrollEvent(e, TouchType.END);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
isJdAndH5ScrollState && recoverRootEleVerticalScroll(touchEvent);
|
|
465
465
|
}
|
|
466
466
|
if (!dispatchTouchMove) {
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
469
|
const parentNode = e.target?.parentNode;
|
|
470
470
|
if (!parentNode) {
|
|
471
471
|
return;
|
|
472
472
|
}
|
|
473
473
|
const event = new TouchEvent('touchmove', e);
|
|
474
474
|
parentNode.dispatchEvent(event);
|
|
475
475
|
};
|
|
476
476
|
if (scrollX && isJdApp && !isIgnorePreventNative) {
|
|
477
477
|
return (
|
|
478
478
|
<ScrollView
|
|
479
479
|
scrollX
|
|
480
480
|
onTouchStart={changeTouchStart}
|
|
481
481
|
onTouchEnd={changeTouchEnd}
|
|
482
482
|
onTouchCancel={changeTouchEnd}
|
|
483
483
|
onTouchMove={changeTouchMove}
|
|
484
484
|
enhanced
|
|
485
485
|
showScrollbar={false}
|
|
486
486
|
style={style}
|
|
487
487
|
className={classNames(
|
|
488
488
|
className,
|
|
489
489
|
{
|
|
490
490
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
491
491
|
},
|
|
492
492
|
'J_customScroll',
|
|
493
493
|
)}
|
|
494
494
|
{...otherProps}
|
|
495
495
|
>
|
|
496
496
|
{children}
|
|
497
497
|
</ScrollView>
|
|
498
498
|
);
|
|
499
499
|
} else {
|
|
500
500
|
return (
|
|
501
501
|
<ScrollView
|
|
502
502
|
scrollX
|
|
503
503
|
enhanced
|
|
504
504
|
showScrollbar={false}
|
|
505
505
|
{...otherProps}
|
|
506
506
|
className={classNames(
|
|
507
507
|
className,
|
|
508
508
|
{
|
|
509
509
|
[customScrollViewStyle['d-custom-ios-mini-extend-border-radius']]:
|
|
510
510
|
isIosDevice && isWxMin && scrollX && style['borderRadius'],
|
|
511
511
|
},
|
|
512
512
|
{
|
|
513
513
|
[customScrollViewStyle['d-custom-ios-h5-extend-border-radius']]: isIosDevice,
|
|
514
514
|
},
|
|
515
515
|
{
|
|
516
516
|
[customScrollViewStyle['d-custom-mini-hide-scroll']]: isWxMin,
|
|
517
517
|
},
|
|
518
518
|
)}
|
|
519
519
|
style={style}
|
|
520
520
|
>
|
|
521
521
|
{children}
|
|
522
522
|
</ScrollView>
|
|
523
523
|
);
|
|
524
524
|
}
|
|
525
525
|
style: {},
|
|
526
526
|
scrollX: false,
|
|
527
527
|
scrollY: false,
|
|
528
528
|
scrollWithAnimation: true,
|
|
529
529
|
iosNeedDisableVertical: false,
|
|
530
530
|
className: null,
|
|
531
531
|
dispatchTouchMove: true,
|
package/dist/open/api/util.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {
|
|
2
1
|
dateFormat,
|
|
3
2
|
showSuccessToast,
|
|
4
3
|
showFailToast,
|
|
5
4
|
showNormalToast,
|
|
6
5
|
isJdApp,
|
|
7
6
|
isH5AndJdShopView,
|
|
8
7
|
isH5,
|
|
9
8
|
isH5AndJdShopViewH5Scroll,
|
|
10
9
|
stopNativeScrollEvent,
|
|
11
10
|
pxTransformFromData,
|
|
12
11
|
remoteCustomReport,
|
|
13
12
|
isLanguageForEn,
|
|
14
13
|
lodashThrottle,
|
|
15
14
|
dateFormat,
|
|
16
15
|
showSuccessToast,
|
|
17
16
|
showFailToast,
|
|
18
17
|
showNormalToast,
|
|
19
18
|
openDialog: openTaroEventDialog,
|
|
20
19
|
closeDialog: closeTaroEventDialog,
|
|
21
20
|
isJdApp,
|
|
22
21
|
isH5AndJdShopView,
|
|
23
22
|
isH5,
|
|
24
23
|
isH5AndJdShopViewH5Scroll,
|
|
25
24
|
stopNativeScrollEvent,
|
|
26
25
|
pxTransformFromData,
|
|
27
26
|
remoteCustomReport,
|
|
28
27
|
isLanguageForEn,
|
|
29
28
|
lodashThrottle,
|
|
29
|
+
import {
|
|
30
30
|
dateFormat,
|
|
31
31
|
showSuccessToast,
|
|
32
32
|
showFailToast,
|
|
33
33
|
showNormalToast,
|
|
34
34
|
isJdApp,
|
|
35
35
|
isH5AndJdShopView,
|
|
36
36
|
isH5,
|
|
37
37
|
isH5AndJdShopViewH5Scroll,
|
|
38
38
|
stopNativeScrollEvent,
|
|
39
39
|
pxTransformFromData,
|
|
40
40
|
remoteCustomReport,
|
|
41
41
|
isLanguageForEn,
|
|
42
42
|
lodashThrottle,
|
|
43
43
|
countStringify,
|
|
44
44
|
dateFormat,
|
|
45
45
|
countFormat: countStringify,
|
|
46
46
|
showSuccessToast,
|
|
47
47
|
showFailToast,
|
|
48
48
|
showNormalToast,
|
|
49
49
|
openDialog: openTaroEventDialog,
|
|
50
50
|
closeDialog: closeTaroEventDialog,
|
|
51
51
|
isJdApp,
|
|
52
52
|
isH5AndJdShopView,
|
|
53
53
|
isH5,
|
|
54
54
|
isH5AndJdShopViewH5Scroll,
|
|
55
55
|
stopNativeScrollEvent,
|
|
56
56
|
pxTransformFromData,
|
|
57
57
|
remoteCustomReport,
|
|
58
58
|
isLanguageForEn,
|
|
59
59
|
lodashThrottle,
|