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