@mpxjs/webpack-plugin 2.9.65 → 2.9.67
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/lib/dependencies/RecordGlobalComponentsDependency.js +11 -12
- package/lib/dependencies/RecordRuntimeInfoDependency.js +1 -1
- package/lib/index.js +28 -8
- package/lib/json-compiler/index.js +2 -11
- package/lib/loader.js +24 -45
- package/lib/native-loader.js +49 -64
- package/lib/platform/json/wx/index.js +3 -10
- package/lib/platform/style/wx/index.js +32 -56
- package/lib/react/index.js +4 -3
- package/lib/react/processJSON.js +5 -13
- package/lib/react/processMainScript.js +7 -3
- package/lib/react/processScript.js +3 -4
- package/lib/react/processTemplate.js +6 -4
- package/lib/resolver/AddModePlugin.js +17 -4
- package/lib/runtime/components/react/context.ts +8 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/mpx-button.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +30 -17
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +33 -24
- package/lib/runtime/components/react/dist/mpx-icon.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +44 -38
- package/lib/runtime/components/react/dist/mpx-label.jsx +10 -7
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +10 -17
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +378 -294
- package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +30 -17
- package/lib/runtime/components/react/dist/mpx-radio.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +58 -30
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +77 -77
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +8 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +31 -12
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +2 -2
- package/lib/runtime/components/react/dist/useAnimationHooks.js +303 -0
- package/lib/runtime/components/react/dist/utils.jsx +13 -3
- package/lib/runtime/components/react/getInnerListeners.ts +1 -0
- package/lib/runtime/components/react/mpx-button.tsx +1 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +52 -29
- package/lib/runtime/components/react/mpx-checkbox.tsx +1 -1
- package/lib/runtime/components/react/mpx-form.tsx +42 -34
- package/lib/runtime/components/react/mpx-icon.tsx +1 -1
- package/lib/runtime/components/react/mpx-image/index.tsx +2 -3
- package/lib/runtime/components/react/mpx-input.tsx +68 -66
- package/lib/runtime/components/react/mpx-label.tsx +11 -8
- package/lib/runtime/components/react/mpx-movable-area.tsx +11 -19
- package/lib/runtime/components/react/mpx-movable-view.tsx +456 -334
- package/lib/runtime/components/react/mpx-navigator.tsx +1 -1
- package/lib/runtime/components/react/mpx-radio-group.tsx +55 -29
- package/lib/runtime/components/react/mpx-radio.tsx +1 -1
- package/lib/runtime/components/react/mpx-root-portal.tsx +1 -1
- package/lib/runtime/components/react/mpx-scroll-view.tsx +92 -37
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +77 -76
- package/lib/runtime/components/react/mpx-swiper/index.tsx +2 -1
- package/lib/runtime/components/react/mpx-swiper-item.tsx +1 -1
- package/lib/runtime/components/react/mpx-switch.tsx +10 -2
- package/lib/runtime/components/react/mpx-text.tsx +1 -1
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +40 -20
- package/lib/runtime/components/react/mpx-web-view.tsx +2 -2
- package/lib/runtime/components/react/types/common.ts +8 -2
- package/lib/runtime/components/react/useAnimationHooks.ts +332 -0
- package/lib/runtime/components/react/useNodesRef.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +23 -6
- package/lib/runtime/optionProcessorReact.js +0 -15
- package/lib/runtime/swanHelper.wxs +1 -1
- package/lib/style-compiler/index.js +1 -1
- package/lib/style-compiler/plugins/scope-id.js +1 -0
- package/lib/template-compiler/compiler.js +68 -33
- package/lib/template-compiler/index.js +4 -4
- package/lib/utils/pre-process-json.js +113 -0
- package/lib/web/index.js +5 -4
- package/lib/web/processJSON.js +5 -13
- package/lib/web/processTemplate.js +2 -2
- package/package.json +5 -4
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ✔ bindchange
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
JSX,
|
|
6
|
+
useRef,
|
|
7
|
+
forwardRef,
|
|
8
|
+
ReactNode,
|
|
9
|
+
useContext,
|
|
10
|
+
useMemo,
|
|
11
|
+
useEffect
|
|
12
|
+
} from 'react'
|
|
13
|
+
import {
|
|
14
|
+
View,
|
|
15
|
+
NativeSyntheticEvent,
|
|
16
|
+
ViewStyle
|
|
17
|
+
} from 'react-native'
|
|
6
18
|
import { warn } from '@mpxjs/utils'
|
|
19
|
+
|
|
7
20
|
import { FormContext, FormFieldValue, RadioGroupContext, GroupValue } from './context'
|
|
8
21
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
9
22
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
@@ -32,10 +45,13 @@ const radioGroup = forwardRef<
|
|
|
32
45
|
'external-var-context': externalVarContext,
|
|
33
46
|
'parent-font-size': parentFontSize,
|
|
34
47
|
'parent-width': parentWidth,
|
|
35
|
-
'parent-height': parentHeight
|
|
36
|
-
bindchange
|
|
48
|
+
'parent-height': parentHeight
|
|
37
49
|
} = props
|
|
38
50
|
|
|
51
|
+
const propsRef = useRef<any>({})
|
|
52
|
+
|
|
53
|
+
propsRef.current = props
|
|
54
|
+
|
|
39
55
|
const formContext = useContext(FormContext)
|
|
40
56
|
|
|
41
57
|
let formValuesMap: Map<string, FormFieldValue> | undefined
|
|
@@ -70,7 +86,7 @@ const radioGroup = forwardRef<
|
|
|
70
86
|
|
|
71
87
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
|
|
72
88
|
|
|
73
|
-
const
|
|
89
|
+
const getValue = (): string | undefined => {
|
|
74
90
|
for (const key in groupValue) {
|
|
75
91
|
if (groupValue[key].checked) {
|
|
76
92
|
return key
|
|
@@ -78,10 +94,6 @@ const radioGroup = forwardRef<
|
|
|
78
94
|
}
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
const getValue = () => {
|
|
82
|
-
return getSelectionValue()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
97
|
const resetValue = () => {
|
|
86
98
|
Object.keys(groupValue).forEach((key) => {
|
|
87
99
|
groupValue[key].checked = false
|
|
@@ -96,25 +108,39 @@ const radioGroup = forwardRef<
|
|
|
96
108
|
formValuesMap.set(props.name, { getValue, resetValue })
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
if (formValuesMap && props.name) {
|
|
114
|
+
formValuesMap.delete(props.name)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, [])
|
|
118
|
+
|
|
119
|
+
const contextValue = useMemo(() => {
|
|
120
|
+
const notifyChange = (
|
|
121
|
+
evt: NativeSyntheticEvent<TouchEvent>
|
|
122
|
+
) => {
|
|
123
|
+
const { bindchange } = propsRef.current
|
|
124
|
+
bindchange &&
|
|
125
|
+
bindchange(
|
|
126
|
+
getCustomEvent(
|
|
127
|
+
'tap',
|
|
128
|
+
evt,
|
|
129
|
+
{
|
|
130
|
+
layoutRef,
|
|
131
|
+
detail: {
|
|
132
|
+
value: getValue()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
propsRef.current
|
|
136
|
+
)
|
|
115
137
|
)
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
groupValue,
|
|
141
|
+
notifyChange
|
|
142
|
+
}
|
|
143
|
+
}, [])
|
|
118
144
|
|
|
119
145
|
const innerProps = useInnerProps(
|
|
120
146
|
props,
|
|
@@ -131,7 +157,7 @@ const radioGroup = forwardRef<
|
|
|
131
157
|
|
|
132
158
|
return (
|
|
133
159
|
<View {...innerProps}>
|
|
134
|
-
<RadioGroupContext.Provider value={
|
|
160
|
+
<RadioGroupContext.Provider value={contextValue}>
|
|
135
161
|
{
|
|
136
162
|
wrapChildren(
|
|
137
163
|
props,
|
|
@@ -146,6 +172,6 @@ const radioGroup = forwardRef<
|
|
|
146
172
|
)
|
|
147
173
|
})
|
|
148
174
|
|
|
149
|
-
radioGroup.displayName = '
|
|
175
|
+
radioGroup.displayName = 'MpxRadioGroup'
|
|
150
176
|
|
|
151
177
|
export default radioGroup
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* ✔ lower-threshold
|
|
6
6
|
* ✔ scroll-top
|
|
7
7
|
* ✔ scroll-left
|
|
8
|
-
*
|
|
8
|
+
* ✔ scroll-into-view
|
|
9
9
|
* ✔ scroll-with-animation
|
|
10
10
|
* ✔ enable-back-to-top
|
|
11
11
|
* ✘ enable-passive
|
|
@@ -33,12 +33,13 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { ScrollView } from 'react-native-gesture-handler'
|
|
35
35
|
import { View, RefreshControl, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle } from 'react-native'
|
|
36
|
-
import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef } from 'react'
|
|
36
|
+
import { JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef, useContext } from 'react'
|
|
37
37
|
import { useAnimatedRef } from 'react-native-reanimated'
|
|
38
38
|
import { warn } from '@mpxjs/utils'
|
|
39
39
|
import useInnerProps, { getCustomEvent } from './getInnerListeners'
|
|
40
40
|
import useNodesRef, { HandlerRef } from './useNodesRef'
|
|
41
|
-
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren } from './utils'
|
|
41
|
+
import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, flatGesture, GestureHandler } from './utils'
|
|
42
|
+
import { IntersectionObserverContext } from './context'
|
|
42
43
|
|
|
43
44
|
interface ScrollViewProps {
|
|
44
45
|
children?: ReactNode;
|
|
@@ -60,11 +61,15 @@ interface ScrollViewProps {
|
|
|
60
61
|
'scroll-top'?: number;
|
|
61
62
|
'scroll-left'?: number;
|
|
62
63
|
'enable-offset'?: boolean;
|
|
64
|
+
'scroll-into-view'?: string;
|
|
65
|
+
'enable-trigger-intersection-observer'?: boolean;
|
|
63
66
|
'enable-var'?: boolean;
|
|
64
67
|
'external-var-context'?: Record<string, any>;
|
|
65
68
|
'parent-font-size'?: number;
|
|
66
69
|
'parent-width'?: number;
|
|
67
70
|
'parent-height'?: number;
|
|
71
|
+
'wait-for'?: Array<GestureHandler>;
|
|
72
|
+
'simultaneous-handlers'?: Array<GestureHandler>;
|
|
68
73
|
bindscrolltoupper?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
69
74
|
bindscrolltolower?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
70
75
|
bindscroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
@@ -76,6 +81,7 @@ interface ScrollViewProps {
|
|
|
76
81
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
77
82
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
78
83
|
bindscrollend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
84
|
+
__selectRef?: (selector: string, nodeType: 'node' | 'component', all?: boolean) => HandlerRef<any, any>
|
|
79
85
|
}
|
|
80
86
|
type ScrollAdditionalProps = {
|
|
81
87
|
pinchGestureEnabled: boolean;
|
|
@@ -95,6 +101,7 @@ type ScrollAdditionalProps = {
|
|
|
95
101
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
96
102
|
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
97
103
|
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
104
|
+
onScrollBeginDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
98
105
|
onScrollEndDrag?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
99
106
|
onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
100
107
|
};
|
|
@@ -104,9 +111,16 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
104
111
|
enhanced = false,
|
|
105
112
|
bounces = true,
|
|
106
113
|
style = {},
|
|
114
|
+
binddragstart,
|
|
115
|
+
binddragging,
|
|
116
|
+
binddragend,
|
|
117
|
+
bindtouchstart,
|
|
118
|
+
bindtouchmove,
|
|
119
|
+
bindtouchend,
|
|
107
120
|
'scroll-x': scrollX = false,
|
|
108
121
|
'scroll-y': scrollY = false,
|
|
109
122
|
'enable-back-to-top': enableBackToTop = false,
|
|
123
|
+
'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false,
|
|
110
124
|
'paging-enabled': pagingEnabled = false,
|
|
111
125
|
'upper-threshold': upperThreshold = 50,
|
|
112
126
|
'lower-threshold': lowerThreshold = 50,
|
|
@@ -115,13 +129,23 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
115
129
|
'refresher-default-style': refresherDefaultStyle,
|
|
116
130
|
'refresher-background': refresherBackground,
|
|
117
131
|
'show-scrollbar': showScrollbar = true,
|
|
132
|
+
'scroll-into-view': scrollIntoView = '',
|
|
133
|
+
'scroll-top': scrollTop = 0,
|
|
134
|
+
'scroll-left': scrollLeft = 0,
|
|
135
|
+
'refresher-triggered': refresherTriggered,
|
|
118
136
|
'enable-var': enableVar,
|
|
119
137
|
'external-var-context': externalVarContext,
|
|
120
138
|
'parent-font-size': parentFontSize,
|
|
121
139
|
'parent-width': parentWidth,
|
|
122
|
-
'parent-height': parentHeight
|
|
140
|
+
'parent-height': parentHeight,
|
|
141
|
+
'simultaneous-handlers': originSimultaneousHandlers,
|
|
142
|
+
'wait-for': waitFor,
|
|
143
|
+
__selectRef
|
|
123
144
|
} = props
|
|
124
145
|
|
|
146
|
+
const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
|
|
147
|
+
const waitForHandlers = flatGesture(waitFor)
|
|
148
|
+
|
|
125
149
|
const [refreshing, setRefreshing] = useState(true)
|
|
126
150
|
|
|
127
151
|
const snapScrollTop = useRef(0)
|
|
@@ -139,6 +163,9 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
139
163
|
const hasCallScrollToUpper = useRef(true)
|
|
140
164
|
const hasCallScrollToLower = useRef(false)
|
|
141
165
|
const initialTimeout = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
166
|
+
const intersectionObservers = useContext(IntersectionObserverContext)
|
|
167
|
+
|
|
168
|
+
const snapScrollIntoView = useRef<string>('')
|
|
142
169
|
|
|
143
170
|
const {
|
|
144
171
|
normalStyle,
|
|
@@ -162,7 +189,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
162
189
|
fastDeceleration: false,
|
|
163
190
|
decelerationDisabled: false,
|
|
164
191
|
scrollTo: scrollToOffset
|
|
165
|
-
}
|
|
192
|
+
},
|
|
193
|
+
gestureRef: scrollViewRef
|
|
166
194
|
})
|
|
167
195
|
|
|
168
196
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout })
|
|
@@ -172,27 +200,41 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
172
200
|
}
|
|
173
201
|
useEffect(() => {
|
|
174
202
|
if (
|
|
175
|
-
snapScrollTop.current !==
|
|
176
|
-
snapScrollLeft.current !== props['scroll-left']
|
|
203
|
+
snapScrollTop.current !== scrollTop || snapScrollLeft.current !== scrollLeft
|
|
177
204
|
) {
|
|
178
|
-
snapScrollTop.current = props['scroll-top'] || 0
|
|
179
|
-
snapScrollLeft.current = props['scroll-left'] || 0
|
|
180
|
-
|
|
181
205
|
initialTimeout.current = setTimeout(() => {
|
|
182
|
-
scrollToOffset(
|
|
206
|
+
scrollToOffset(scrollLeft, scrollTop)
|
|
183
207
|
}, 0)
|
|
184
208
|
|
|
185
209
|
return () => {
|
|
186
210
|
initialTimeout.current && clearTimeout(initialTimeout.current)
|
|
187
211
|
}
|
|
188
212
|
}
|
|
189
|
-
}, [
|
|
213
|
+
}, [scrollTop, scrollLeft])
|
|
190
214
|
|
|
191
215
|
useEffect(() => {
|
|
192
|
-
if (refreshing !==
|
|
193
|
-
setRefreshing(!!
|
|
216
|
+
if (refreshing !== refresherTriggered) {
|
|
217
|
+
setRefreshing(!!refresherTriggered)
|
|
194
218
|
}
|
|
195
|
-
}, [
|
|
219
|
+
}, [refresherTriggered])
|
|
220
|
+
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (scrollIntoView && __selectRef && snapScrollIntoView.current !== scrollIntoView) {
|
|
223
|
+
snapScrollIntoView.current = scrollIntoView || ''
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
const refs = __selectRef(`#${scrollIntoView}`, 'node')
|
|
226
|
+
if (refs) {
|
|
227
|
+
const { nodeRef } = refs.getNodeInstance()
|
|
228
|
+
nodeRef.current?.measureLayout(
|
|
229
|
+
scrollViewRef.current,
|
|
230
|
+
(left: number, top:number) => {
|
|
231
|
+
scrollToOffset(left, top)
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
}, [scrollIntoView])
|
|
196
238
|
|
|
197
239
|
function selectLength (size: { height: number; width: number }) {
|
|
198
240
|
return !scrollX ? size.height : size.width
|
|
@@ -285,6 +327,11 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
285
327
|
}, props)
|
|
286
328
|
)
|
|
287
329
|
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
330
|
+
if (enableTriggerIntersectionObserver && intersectionObservers) {
|
|
331
|
+
for (const key in intersectionObservers) {
|
|
332
|
+
intersectionObservers[key].throttleMeasure()
|
|
333
|
+
}
|
|
334
|
+
}
|
|
288
335
|
}
|
|
289
336
|
|
|
290
337
|
function onScrollEnd (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
@@ -313,6 +360,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
313
360
|
scrollViewRef.current.scrollTo({ x, y, animated: !!scrollWithAnimation })
|
|
314
361
|
scrollOptions.current.scrollLeft = x
|
|
315
362
|
scrollOptions.current.scrollTop = y
|
|
363
|
+
snapScrollLeft.current = x
|
|
364
|
+
snapScrollTop.current = y
|
|
316
365
|
}
|
|
317
366
|
}
|
|
318
367
|
|
|
@@ -325,7 +374,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
325
374
|
}
|
|
326
375
|
|
|
327
376
|
function onScrollTouchStart (e: NativeSyntheticEvent<TouchEvent>) {
|
|
328
|
-
const {
|
|
377
|
+
const { bindtouchstart } = props
|
|
329
378
|
bindtouchstart && bindtouchstart(e)
|
|
330
379
|
if (enhanced) {
|
|
331
380
|
binddragstart &&
|
|
@@ -341,7 +390,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
341
390
|
}
|
|
342
391
|
}
|
|
343
392
|
function onScrollTouchMove (e: NativeSyntheticEvent<TouchEvent>) {
|
|
344
|
-
const { binddragging, bindtouchmove, enhanced } = props
|
|
345
393
|
bindtouchmove && bindtouchmove(e)
|
|
346
394
|
if (enhanced) {
|
|
347
395
|
binddragging &&
|
|
@@ -357,27 +405,27 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
357
405
|
}
|
|
358
406
|
}
|
|
359
407
|
|
|
360
|
-
function
|
|
361
|
-
|
|
408
|
+
function onScrollTouchEnd (e: NativeSyntheticEvent<TouchEvent>) {
|
|
409
|
+
bindtouchend && bindtouchend(e)
|
|
362
410
|
if (enhanced) {
|
|
363
|
-
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
|
|
364
|
-
const { width: scrollWidth, height: scrollHeight } = e.nativeEvent.contentSize
|
|
365
411
|
binddragend &&
|
|
366
412
|
binddragend(
|
|
367
413
|
getCustomEvent('dragend', e, {
|
|
368
414
|
detail: {
|
|
369
|
-
scrollLeft: scrollLeft,
|
|
370
|
-
scrollTop: scrollTop
|
|
371
|
-
scrollHeight,
|
|
372
|
-
scrollWidth
|
|
415
|
+
scrollLeft: scrollOptions.current.scrollLeft || 0,
|
|
416
|
+
scrollTop: scrollOptions.current.scrollTop || 0
|
|
373
417
|
},
|
|
374
418
|
layoutRef
|
|
375
419
|
}, props)
|
|
376
420
|
)
|
|
377
|
-
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
378
421
|
}
|
|
379
422
|
}
|
|
380
423
|
|
|
424
|
+
function onScrollDrag (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
425
|
+
const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset
|
|
426
|
+
updateScrollOptions(e, { scrollLeft, scrollTop })
|
|
427
|
+
}
|
|
428
|
+
|
|
381
429
|
let scrollAdditionalProps: ScrollAdditionalProps = {
|
|
382
430
|
style: { ...innerStyle, ...layoutStyle },
|
|
383
431
|
pinchGestureEnabled: false,
|
|
@@ -390,11 +438,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
390
438
|
ref: scrollViewRef,
|
|
391
439
|
onScroll: onScroll,
|
|
392
440
|
onContentSizeChange: onContentSizeChange,
|
|
393
|
-
bindtouchstart: onScrollTouchStart,
|
|
394
|
-
bindtouchmove: onScrollTouchMove,
|
|
395
|
-
|
|
441
|
+
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
|
|
442
|
+
bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
|
|
443
|
+
bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
|
|
444
|
+
onScrollBeginDrag: onScrollDrag,
|
|
445
|
+
onScrollEndDrag: onScrollDrag,
|
|
396
446
|
onMomentumScrollEnd: onScrollEnd,
|
|
397
|
-
...layoutProps
|
|
447
|
+
...layoutProps,
|
|
448
|
+
...(simultaneousHandlers ? { simultaneousHandlers } : {}),
|
|
449
|
+
...(waitForHandlers ? { waitFor: waitForHandlers } : {})
|
|
398
450
|
}
|
|
399
451
|
if (enhanced) {
|
|
400
452
|
scrollAdditionalProps = {
|
|
@@ -403,10 +455,13 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
403
455
|
pagingEnabled
|
|
404
456
|
}
|
|
405
457
|
}
|
|
458
|
+
|
|
406
459
|
const innerProps = useInnerProps(props, scrollAdditionalProps, [
|
|
460
|
+
'id',
|
|
407
461
|
'scroll-x',
|
|
408
462
|
'scroll-y',
|
|
409
463
|
'enable-back-to-top',
|
|
464
|
+
'enable-trigger-intersection-observer',
|
|
410
465
|
'paging-enabled',
|
|
411
466
|
'show-scrollbar',
|
|
412
467
|
'upper-threshold',
|
|
@@ -439,12 +494,12 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
439
494
|
{...innerProps}
|
|
440
495
|
refreshControl={refresherEnabled
|
|
441
496
|
? (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
497
|
+
<RefreshControl
|
|
498
|
+
progressBackgroundColor={refresherBackground}
|
|
499
|
+
refreshing={refreshing}
|
|
500
|
+
onRefresh={onRefresh}
|
|
501
|
+
{...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}
|
|
502
|
+
/>
|
|
448
503
|
)
|
|
449
504
|
: undefined}
|
|
450
505
|
>
|
|
@@ -463,6 +518,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
463
518
|
)
|
|
464
519
|
})
|
|
465
520
|
|
|
466
|
-
_ScrollView.displayName = '
|
|
521
|
+
_ScrollView.displayName = 'MpxScrollView'
|
|
467
522
|
|
|
468
523
|
export default _ScrollView
|