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