@conecli/cone-render 0.8.15-isinview.3 → 0.8.15-taroUpdate.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
inViewCallback
|
|
3
2
|
if (isH5AndJdShopView) {
|
|
4
3
|
useEffect(() => {
|
|
5
4
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
6
5
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
7
6
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
8
7
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
9
8
|
})
|
|
10
9
|
}, [])
|
|
11
10
|
useEffect(() => {
|
|
12
11
|
if(componentShowState){
|
|
13
12
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
14
13
|
console.log('InViewRender -- 店铺H5 展示啦!')
|
|
15
14
|
}
|
|
16
15
|
}, [componentShowState])
|
|
17
16
|
|
|
18
17
|
const dealPageScrollInfo = (res) => {
|
|
19
18
|
console.log(
|
|
20
19
|
'收到滚动信息和模块元素以及容器显示状态',
|
|
21
20
|
res,
|
|
22
21
|
typeof componentLazyRef.current,
|
|
23
22
|
componentShowStateRef.current,
|
|
24
23
|
)
|
|
25
24
|
if (componentLazyRef.current) {
|
|
26
25
|
const eleClientRect =
|
|
27
26
|
componentLazyRef.current.getBoundingClientRect()
|
|
28
27
|
const getContainerHeightOffSetY = res.displayHeight + res.offSetY
|
|
29
28
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
30
29
|
if (!componentShowStateRef.current) {
|
|
31
30
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
32
31
|
componentShowStateRef.current = true
|
|
33
32
|
setComponentShowState(true)
|
|
34
33
|
Taro.nextTick(() => {
|
|
35
34
|
setComponentRenderShowState(true)
|
|
36
35
|
})
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
return (
|
|
42
41
|
<View
|
|
43
42
|
ref={componentLazyRef}
|
|
44
43
|
className={classNames(
|
|
45
44
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
46
45
|
'd-app-floor-lazy-load',
|
|
47
46
|
)}
|
|
48
47
|
style={{
|
|
49
48
|
minHeight: `${
|
|
50
49
|
componentRenderShowState ? 'auto' : height + (typeof height === 'number'? 'px': '')
|
|
51
50
|
}`,
|
|
52
51
|
backgroundColor: componentRenderShowState
|
|
53
52
|
? 'transparent'
|
|
54
53
|
: '#ffffff',
|
|
55
54
|
}}
|
|
56
55
|
>
|
|
57
56
|
{componentShowState ? children : placeholder}
|
|
58
57
|
</View>
|
|
59
58
|
)
|
|
60
59
|
} else {
|
|
61
60
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
62
61
|
console.log('rootDom', rootDom)
|
|
63
62
|
const { ref, inView } = useInView({
|
|
64
63
|
threshold: 0,
|
|
65
64
|
triggerOnce: true,
|
|
66
65
|
root: rootDom || null,
|
|
67
66
|
rootMargin: `0px 0px 0px 0px`,
|
|
68
67
|
})
|
|
69
68
|
console.log('ref', ref)
|
|
70
69
|
console.log('inView', inView)
|
|
71
70
|
useEffect(() => {
|
|
72
71
|
if(inView){
|
|
73
72
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
74
73
|
console.log('InViewRender -- 其它H5 展示啦!')
|
|
75
74
|
}
|
|
76
75
|
}, [inView])
|
|
77
76
|
return (
|
|
78
77
|
<View
|
|
79
78
|
ref={ref}
|
|
80
79
|
style={{
|
|
81
80
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
82
81
|
backgroundColor: 'transparent',
|
|
83
82
|
}}
|
|
84
83
|
>
|
|
85
84
|
{inView ? children : placeholder}
|
|
86
85
|
</View>
|
|
87
86
|
)
|
|
88
87
|
}
|
|
89
88
|
inViewCallback: null,
|
|
89
|
+
import Taro from '@tarojs/taro'
|
|
90
90
|
inViewCallback
|
|
91
91
|
if (isH5AndJdShopView) {
|
|
92
92
|
useEffect(() => {
|
|
93
93
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
94
94
|
!componentShowStateRef.current && dealPageScrollInfo(latestRes)
|
|
95
95
|
Taro.eventCenter.on(TaroEventType.PAGE_SCROLL, (res) => {
|
|
96
96
|
!componentShowStateRef.current && dealPageScrollInfo(res)
|
|
97
97
|
})
|
|
98
98
|
}, [])
|
|
99
99
|
useEffect(() => {
|
|
100
100
|
if(componentShowState){
|
|
101
101
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
102
102
|
console.log('InViewRender -- 店铺H5 展示啦!')
|
|
103
103
|
}
|
|
104
104
|
}, [componentShowState])
|
|
105
105
|
|
|
106
106
|
const dealPageScrollInfo = (res) => {
|
|
107
107
|
if (componentLazyRef.current) {
|
|
108
108
|
const eleClientRect =
|
|
109
109
|
componentLazyRef.current.getBoundingClientRect()
|
|
110
110
|
const getContainerHeightOffSetY = res.displayHeight + res.offSetY
|
|
111
111
|
const eleOffsetTop = Math.ceil(eleClientRect.top)
|
|
112
112
|
if (!componentShowStateRef.current) {
|
|
113
113
|
if (getContainerHeightOffSetY > eleOffsetTop) {
|
|
114
114
|
componentShowStateRef.current = true
|
|
115
115
|
setComponentShowState(true)
|
|
116
116
|
Taro.nextTick(() => {
|
|
117
117
|
setComponentRenderShowState(true)
|
|
118
118
|
})
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
return (
|
|
124
124
|
<View
|
|
125
125
|
ref={componentLazyRef}
|
|
126
126
|
className={classNames(
|
|
127
127
|
lazyLayoutLoadStyle['d-app-floor-lazy-layout-load'],
|
|
128
128
|
'd-app-floor-lazy-load',
|
|
129
129
|
)}
|
|
130
130
|
style={{
|
|
131
131
|
minHeight: `${
|
|
132
132
|
componentRenderShowState ? 'auto' : height + (typeof height === 'number'? 'px': '')
|
|
133
133
|
}`,
|
|
134
134
|
backgroundColor: componentRenderShowState
|
|
135
135
|
? 'transparent'
|
|
136
136
|
: '#ffffff',
|
|
137
137
|
}}
|
|
138
138
|
>
|
|
139
139
|
{componentShowState ? children : placeholder}
|
|
140
140
|
</View>
|
|
141
141
|
)
|
|
142
142
|
} else {
|
|
143
143
|
const rootDom = document.querySelector('#J_shopHomeRoot')
|
|
144
144
|
const { ref, inView } = useInView({
|
|
145
145
|
threshold: 0,
|
|
146
146
|
triggerOnce: true,
|
|
147
147
|
root: rootDom,
|
|
148
148
|
rootMargin: `0px 0px 0px 0px`,
|
|
149
149
|
})
|
|
150
150
|
useEffect(() => {
|
|
151
151
|
if(inView){
|
|
152
152
|
typeof inViewCallback === 'function' && inViewCallback()
|
|
153
153
|
console.log('InViewRender -- 其它H5 展示啦!')
|
|
154
154
|
}
|
|
155
155
|
}, [inView])
|
|
156
156
|
return (
|
|
157
157
|
<View
|
|
158
158
|
ref={ref}
|
|
159
159
|
style={{
|
|
160
160
|
minHeight: `${inView ? 'auto' : height + 'px'}`,
|
|
161
161
|
backgroundColor: 'transparent',
|
|
162
162
|
}}
|
|
163
163
|
>
|
|
164
164
|
{inView ? children : placeholder}
|
|
165
165
|
</View>
|
|
166
166
|
)
|
|
167
167
|
}
|
|
168
168
|
inViewCallback: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conecli/cone-render",
|
|
3
|
-
"version": "0.8.15-
|
|
3
|
+
"version": "0.8.15-taroUpdate.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/"
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
],
|
|
61
61
|
"author": "conecli",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@tarojs/cli": "
|
|
64
|
-
"@tarojs/components": "3.
|
|
65
|
-
"@tarojs/plugin-framework-react": "3.
|
|
66
|
-
"@tarojs/react": "3.
|
|
67
|
-
"@tarojs/runtime": "3.
|
|
68
|
-
"@tarojs/shared": "3.
|
|
69
|
-
"@tarojs/taro": "3.
|
|
70
|
-
"@tarojs/
|
|
71
|
-
"@tarojs/taro-loader": "3.
|
|
72
|
-
"@tarojs/webpack5-runner": "3.
|
|
63
|
+
"@tarojs/cli": "3.6.2",
|
|
64
|
+
"@tarojs/components": "3.6.2",
|
|
65
|
+
"@tarojs/plugin-framework-react": "3.6.2",
|
|
66
|
+
"@tarojs/react": "3.6.2",
|
|
67
|
+
"@tarojs/runtime": "3.6.2",
|
|
68
|
+
"@tarojs/shared": "3.6.2",
|
|
69
|
+
"@tarojs/taro": "3.6.2",
|
|
70
|
+
"@tarojs/plugin-platform-h5": "3.6.2",
|
|
71
|
+
"@tarojs/taro-loader": "3.6.2",
|
|
72
|
+
"@tarojs/webpack5-runner": "3.6.2",
|
|
73
73
|
"art-template": "^4.13.2",
|
|
74
74
|
"gulp-filter": "^7.0.0",
|
|
75
75
|
"normalize.css": "^8.0.1",
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
"@types/webpack-env": "^1.13.6",
|
|
91
91
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
92
92
|
"@typescript-eslint/parser": "^5.20.0",
|
|
93
|
-
"babel-preset-taro": "3.
|
|
93
|
+
"babel-preset-taro": "3.6.2",
|
|
94
94
|
"del": "^6.1.1",
|
|
95
95
|
"escodegen": "^2.0.0",
|
|
96
96
|
"eslint": "^6.8.0",
|
|
97
|
-
"eslint-config-taro": "3.
|
|
97
|
+
"eslint-config-taro": "3.6.2",
|
|
98
98
|
"eslint-plugin-import": "^2.12.0",
|
|
99
99
|
"eslint-plugin-react": "^7.8.2",
|
|
100
100
|
"eslint-plugin-react-hooks": "^4.2.0",
|