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