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