@mpxjs/webpack-plugin 2.10.5-beta.1 → 2.10.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/LICENSE +433 -0
- package/lib/platform/json/wx/index.js +1 -0
- package/lib/platform/template/wx/component-config/button.js +1 -1
- package/lib/platform/template/wx/component-config/index.js +1 -5
- package/lib/platform/template/wx/component-config/input.js +1 -1
- package/lib/react/processJSON.js +6 -7
- package/lib/runtime/components/react/context.ts +3 -12
- package/lib/runtime/components/react/dist/context.js +1 -4
- package/lib/runtime/components/react/dist/mpx-button.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -17
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +13 -13
- package/lib/runtime/components/react/dist/utils.jsx +1 -12
- package/lib/runtime/components/react/mpx-button.tsx +2 -3
- package/lib/runtime/components/react/mpx-scroll-view.tsx +50 -68
- package/lib/runtime/components/react/mpx-web-view.tsx +12 -12
- package/lib/runtime/components/react/utils.tsx +1 -12
- package/lib/runtime/components/web/mpx-scroll-view.vue +4 -21
- package/package.json +4 -4
- package/lib/platform/template/wx/component-config/sticky-header.js +0 -23
- package/lib/platform/template/wx/component-config/sticky-section.js +0 -23
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +0 -115
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +0 -45
- package/lib/runtime/components/react/mpx-sticky-header.tsx +0 -179
- package/lib/runtime/components/react/mpx-sticky-section.tsx +0 -96
- package/lib/runtime/components/web/mpx-sticky-header.vue +0 -91
- package/lib/runtime/components/web/mpx-sticky-section.vue +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useRef, useContext, useMemo, useState } from 'react';
|
|
1
|
+
import { forwardRef, useRef, useContext, useMemo, useState, useEffect } from 'react';
|
|
2
2
|
import { warn, isFunction } from '@mpxjs/utils';
|
|
3
3
|
import Portal from './mpx-portal/index';
|
|
4
4
|
import { getCustomEvent } from './getInnerListeners';
|
|
@@ -74,17 +74,17 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
74
74
|
isNavigateBack.current = false;
|
|
75
75
|
};
|
|
76
76
|
const navigation = useNavigation();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
let beforeRemoveSubscription;
|
|
79
|
+
if (__mpx_mode__ !== 'ios') {
|
|
80
|
+
beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle);
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
if (isFunction(beforeRemoveSubscription)) {
|
|
84
|
+
beforeRemoveSubscription();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, []);
|
|
88
88
|
useNodesRef(props, ref, webViewRef, {
|
|
89
89
|
style: defaultWebViewStyle
|
|
90
90
|
});
|
|
@@ -160,7 +160,7 @@ const _WebView = forwardRef((props, ref) => {
|
|
|
160
160
|
{ // case下不允许直接声明,包个块解决该问题
|
|
161
161
|
const title = postData._documentTitle?.trim();
|
|
162
162
|
if (title !== undefined) {
|
|
163
|
-
navigation && navigation.
|
|
163
|
+
navigation && navigation.setOptions({ title });
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
break;
|
|
@@ -441,18 +441,7 @@ export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout
|
|
|
441
441
|
if (enableOffset) {
|
|
442
442
|
nodeRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
|
|
443
443
|
const { y: navigationY = 0 } = navigation?.layout || {};
|
|
444
|
-
layoutRef.current = {
|
|
445
|
-
x,
|
|
446
|
-
y: y - navigationY,
|
|
447
|
-
width,
|
|
448
|
-
height,
|
|
449
|
-
offsetLeft,
|
|
450
|
-
offsetTop: offsetTop - navigationY,
|
|
451
|
-
_x: x,
|
|
452
|
-
_y: y,
|
|
453
|
-
_offsetLeft: offsetLeft,
|
|
454
|
-
_offsetTop: offsetTop
|
|
455
|
-
};
|
|
444
|
+
layoutRef.current = { x, y: y - navigationY, width, height, offsetLeft, offsetTop: offsetTop - navigationY };
|
|
456
445
|
});
|
|
457
446
|
}
|
|
458
447
|
onLayout && onLayout(e);
|
|
@@ -42,8 +42,7 @@ import {
|
|
|
42
42
|
TextStyle,
|
|
43
43
|
Animated,
|
|
44
44
|
Easing,
|
|
45
|
-
NativeSyntheticEvent
|
|
46
|
-
useAnimatedValue
|
|
45
|
+
NativeSyntheticEvent
|
|
47
46
|
} from 'react-native'
|
|
48
47
|
import { warn } from '@mpxjs/utils'
|
|
49
48
|
import { GestureDetector, PanGesture } from 'react-native-gesture-handler'
|
|
@@ -158,7 +157,7 @@ const timer = (data: any, time = 3000) => new Promise((resolve) => {
|
|
|
158
157
|
})
|
|
159
158
|
|
|
160
159
|
const Loading = ({ alone = false }: { alone: boolean }): JSX.Element => {
|
|
161
|
-
const image =
|
|
160
|
+
const image = useRef(new Animated.Value(0)).current
|
|
162
161
|
|
|
163
162
|
const rotate = image.interpolate({
|
|
164
163
|
inputRange: [0, 1],
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* ✔ bindscroll
|
|
33
33
|
*/
|
|
34
34
|
import { ScrollView, RefreshControl, Gesture, GestureDetector } from 'react-native-gesture-handler'
|
|
35
|
-
import { View, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle
|
|
35
|
+
import { View, NativeSyntheticEvent, NativeScrollEvent, LayoutChangeEvent, ViewStyle } from 'react-native'
|
|
36
36
|
import { isValidElement, Children, JSX, ReactNode, RefObject, useRef, useState, useEffect, forwardRef, useContext, useMemo, createElement } from 'react'
|
|
37
37
|
import Animated, { useAnimatedRef, useSharedValue, withTiming, useAnimatedStyle, runOnJS } from 'react-native-reanimated'
|
|
38
38
|
import { warn, hasOwn } from '@mpxjs/utils'
|
|
@@ -43,48 +43,48 @@ import { IntersectionObserverContext, ScrollViewContext } from './context'
|
|
|
43
43
|
import Portal from './mpx-portal'
|
|
44
44
|
|
|
45
45
|
interface ScrollViewProps {
|
|
46
|
-
children?: ReactNode
|
|
47
|
-
enhanced?: boolean
|
|
48
|
-
bounces?: boolean
|
|
49
|
-
style?: ViewStyle
|
|
50
|
-
|
|
51
|
-
'scroll-
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'refresher-
|
|
60
|
-
'refresher-
|
|
61
|
-
'refresher-
|
|
62
|
-
'refresher-
|
|
63
|
-
'
|
|
64
|
-
'scroll-
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'enable-
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
'parent-
|
|
72
|
-
'parent-
|
|
73
|
-
'
|
|
74
|
-
'wait-for'?: Array<GestureHandler
|
|
75
|
-
'simultaneous-handlers'?: Array<GestureHandler
|
|
76
|
-
'scroll-event-throttle'?:number
|
|
77
|
-
bindscrolltoupper?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
78
|
-
bindscrolltolower?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
79
|
-
bindscroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
80
|
-
bindrefresherrefresh?: (event: NativeSyntheticEvent<unknown>) => void
|
|
81
|
-
binddragstart?: (event: NativeSyntheticEvent<DragEvent>) => void
|
|
82
|
-
binddragging?: (event: NativeSyntheticEvent<DragEvent>) => void
|
|
83
|
-
binddragend?: (event: NativeSyntheticEvent<DragEvent>) => void
|
|
84
|
-
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
85
|
-
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
86
|
-
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
87
|
-
bindscrollend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
46
|
+
children?: ReactNode
|
|
47
|
+
enhanced?: boolean
|
|
48
|
+
bounces?: boolean
|
|
49
|
+
style?: ViewStyle
|
|
50
|
+
scrollEventThrottle?: number
|
|
51
|
+
'scroll-x'?: boolean
|
|
52
|
+
'scroll-y'?: boolean
|
|
53
|
+
'enable-back-to-top'?: boolean
|
|
54
|
+
'show-scrollbar'?: boolean
|
|
55
|
+
'paging-enabled'?: boolean
|
|
56
|
+
'upper-threshold'?: number
|
|
57
|
+
'lower-threshold'?: number
|
|
58
|
+
'scroll-with-animation'?: boolean
|
|
59
|
+
'refresher-triggered'?: boolean
|
|
60
|
+
'refresher-enabled'?: boolean
|
|
61
|
+
'refresher-default-style'?: 'black' | 'white' | 'none'
|
|
62
|
+
'refresher-background'?: string
|
|
63
|
+
'refresher-threshold'?: number
|
|
64
|
+
'scroll-top'?: number
|
|
65
|
+
'scroll-left'?: number
|
|
66
|
+
'enable-offset'?: boolean
|
|
67
|
+
'scroll-into-view'?: string
|
|
68
|
+
'enable-trigger-intersection-observer'?: boolean
|
|
69
|
+
'enable-var'?: boolean
|
|
70
|
+
'external-var-context'?: Record<string, any>
|
|
71
|
+
'parent-font-size'?: number
|
|
72
|
+
'parent-width'?: number
|
|
73
|
+
'parent-height'?: number
|
|
74
|
+
'wait-for'?: Array<GestureHandler>
|
|
75
|
+
'simultaneous-handlers'?: Array<GestureHandler>
|
|
76
|
+
'scroll-event-throttle'?: number
|
|
77
|
+
bindscrolltoupper?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
78
|
+
bindscrolltolower?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
79
|
+
bindscroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
80
|
+
bindrefresherrefresh?: (event: NativeSyntheticEvent<unknown>) => void
|
|
81
|
+
binddragstart?: (event: NativeSyntheticEvent<DragEvent>) => void
|
|
82
|
+
binddragging?: (event: NativeSyntheticEvent<DragEvent>) => void
|
|
83
|
+
binddragend?: (event: NativeSyntheticEvent<DragEvent>) => void
|
|
84
|
+
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
85
|
+
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
86
|
+
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
87
|
+
bindscrollend?: (event: NativeSyntheticEvent<TouchEvent>) => void
|
|
88
88
|
__selectRef?: (selector: string, nodeType: 'node' | 'component', all?: boolean) => HandlerRef<any, any>
|
|
89
89
|
}
|
|
90
90
|
type ScrollAdditionalProps = {
|
|
@@ -109,8 +109,6 @@ type ScrollAdditionalProps = {
|
|
|
109
109
|
onMomentumScrollEnd?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const AnimatedScrollView = RNAnimated.createAnimatedComponent(ScrollView) as React.ComponentType<any>
|
|
113
|
-
|
|
114
112
|
const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, ScrollViewProps>((scrollViewProps: ScrollViewProps = {}, ref): JSX.Element => {
|
|
115
113
|
const { textProps, innerProps: props = {} } = splitProps(scrollViewProps)
|
|
116
114
|
const {
|
|
@@ -147,13 +145,10 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
147
145
|
'parent-height': parentHeight,
|
|
148
146
|
'simultaneous-handlers': originSimultaneousHandlers,
|
|
149
147
|
'wait-for': waitFor,
|
|
150
|
-
'enable-sticky': enableSticky,
|
|
151
148
|
'scroll-event-throttle': scrollEventThrottle = 0,
|
|
152
149
|
__selectRef
|
|
153
150
|
} = props
|
|
154
151
|
|
|
155
|
-
const scrollOffset = useRef(new RNAnimated.Value(0)).current
|
|
156
|
-
|
|
157
152
|
const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
|
|
158
153
|
const waitForHandlers = flatGesture(waitFor)
|
|
159
154
|
|
|
@@ -223,15 +218,14 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
223
218
|
gestureRef: scrollViewRef
|
|
224
219
|
})
|
|
225
220
|
|
|
226
|
-
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout })
|
|
227
|
-
|
|
228
221
|
const contextValue = useMemo(() => {
|
|
229
222
|
return {
|
|
230
|
-
gestureRef: scrollViewRef
|
|
231
|
-
scrollOffset
|
|
223
|
+
gestureRef: scrollViewRef
|
|
232
224
|
}
|
|
233
225
|
}, [])
|
|
234
226
|
|
|
227
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout })
|
|
228
|
+
|
|
235
229
|
const hasRefresherLayoutRef = useRef(false)
|
|
236
230
|
|
|
237
231
|
// layout 完成前先隐藏,避免安卓闪烁问题
|
|
@@ -493,16 +487,6 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
493
487
|
updateIntersection()
|
|
494
488
|
}
|
|
495
489
|
|
|
496
|
-
const scrollHandler = RNAnimated.event(
|
|
497
|
-
[{ nativeEvent: { contentOffset: { y: scrollOffset } } }],
|
|
498
|
-
{
|
|
499
|
-
useNativeDriver: true,
|
|
500
|
-
listener: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
501
|
-
onScroll(event)
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
)
|
|
505
|
-
|
|
506
490
|
function onScrollDragStart (e: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
507
491
|
hasCallScrollToLower.current = false
|
|
508
492
|
hasCallScrollToUpper.current = false
|
|
@@ -677,7 +661,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
677
661
|
scrollEnabled: !enableScroll ? false : !!(scrollX || scrollY),
|
|
678
662
|
bounces: false,
|
|
679
663
|
ref: scrollViewRef,
|
|
680
|
-
onScroll:
|
|
664
|
+
onScroll: onScroll,
|
|
681
665
|
onContentSizeChange: onContentSizeChange,
|
|
682
666
|
bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
|
|
683
667
|
bindtouchmove: ((enhanced && binddragging) || bindtouchmove) && onScrollTouchMove,
|
|
@@ -732,13 +716,11 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
732
716
|
'bindrefresherrefresh'
|
|
733
717
|
], { layoutRef })
|
|
734
718
|
|
|
735
|
-
const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView
|
|
736
|
-
|
|
737
719
|
const withRefresherScrollView = createElement(
|
|
738
720
|
GestureDetector,
|
|
739
721
|
{ gesture: panGesture },
|
|
740
722
|
createElement(
|
|
741
|
-
|
|
723
|
+
ScrollView,
|
|
742
724
|
innerProps,
|
|
743
725
|
createElement(
|
|
744
726
|
Animated.View,
|
|
@@ -766,8 +748,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
766
748
|
)
|
|
767
749
|
|
|
768
750
|
const commonScrollView = createElement(
|
|
769
|
-
|
|
770
|
-
extendObject(
|
|
751
|
+
ScrollView,
|
|
752
|
+
extendObject(innerProps, {
|
|
771
753
|
refreshControl: refresherEnabled
|
|
772
754
|
? createElement(RefreshControl, extendObject({
|
|
773
755
|
progressBackgroundColor: refresherBackground,
|
|
@@ -122,17 +122,17 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
122
122
|
|
|
123
123
|
const navigation = useNavigation()
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
let beforeRemoveSubscription:any
|
|
127
|
+
if (__mpx_mode__ !== 'ios') {
|
|
128
|
+
beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
|
|
129
|
+
}
|
|
130
|
+
return () => {
|
|
131
|
+
if (isFunction(beforeRemoveSubscription)) {
|
|
132
|
+
beforeRemoveSubscription()
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, [])
|
|
136
136
|
|
|
137
137
|
useNodesRef<WebView, WebViewProps>(props, ref, webViewRef, {
|
|
138
138
|
style: defaultWebViewStyle
|
|
@@ -212,7 +212,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
|
|
|
212
212
|
{ // case下不允许直接声明,包个块解决该问题
|
|
213
213
|
const title = postData._documentTitle?.trim()
|
|
214
214
|
if (title !== undefined) {
|
|
215
|
-
navigation && navigation.
|
|
215
|
+
navigation && navigation.setOptions({ title })
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
break
|
|
@@ -526,18 +526,7 @@ export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout
|
|
|
526
526
|
if (enableOffset) {
|
|
527
527
|
nodeRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => {
|
|
528
528
|
const { y: navigationY = 0 } = navigation?.layout || {}
|
|
529
|
-
layoutRef.current = {
|
|
530
|
-
x,
|
|
531
|
-
y: y - navigationY,
|
|
532
|
-
width,
|
|
533
|
-
height,
|
|
534
|
-
offsetLeft,
|
|
535
|
-
offsetTop: offsetTop - navigationY,
|
|
536
|
-
_x: x,
|
|
537
|
-
_y: y,
|
|
538
|
-
_offsetLeft: offsetLeft,
|
|
539
|
-
_offsetTop: offsetTop
|
|
540
|
-
}
|
|
529
|
+
layoutRef.current = { x, y: y - navigationY, width, height, offsetLeft, offsetTop: offsetTop - navigationY }
|
|
541
530
|
})
|
|
542
531
|
}
|
|
543
532
|
onLayout && onLayout(e)
|
|
@@ -44,7 +44,6 @@
|
|
|
44
44
|
enhanced: Boolean,
|
|
45
45
|
refresherEnabled: Boolean,
|
|
46
46
|
refresherTriggered: Boolean,
|
|
47
|
-
enableSticky: Boolean,
|
|
48
47
|
refresherThreshold: {
|
|
49
48
|
type: Number,
|
|
50
49
|
default: 45
|
|
@@ -58,16 +57,6 @@
|
|
|
58
57
|
default: ''
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
|
-
provide () {
|
|
62
|
-
return {
|
|
63
|
-
scrollOffset: {
|
|
64
|
-
get: () => this.lastY
|
|
65
|
-
},
|
|
66
|
-
refreshVersion: {
|
|
67
|
-
get: () => this.refreshVersion
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
60
|
data () {
|
|
72
61
|
return {
|
|
73
62
|
isLoading: false,
|
|
@@ -79,8 +68,7 @@
|
|
|
79
68
|
lastContentWidth: 0,
|
|
80
69
|
lastContentHeight: 0,
|
|
81
70
|
lastWrapperWidth: 0,
|
|
82
|
-
lastWrapperHeight: 0
|
|
83
|
-
refreshVersion: 0
|
|
71
|
+
lastWrapperHeight: 0
|
|
84
72
|
}
|
|
85
73
|
},
|
|
86
74
|
computed: {
|
|
@@ -234,9 +222,6 @@
|
|
|
234
222
|
stop: 56
|
|
235
223
|
}
|
|
236
224
|
}
|
|
237
|
-
if(this.enableSticky) {
|
|
238
|
-
originBsOptions.useTransition = false
|
|
239
|
-
}
|
|
240
225
|
const bsOptions = Object.assign({}, originBsOptions, this.scrollOptions, { observeDOM: false })
|
|
241
226
|
this.bs = new BScroll(this.$refs.wrapper, bsOptions)
|
|
242
227
|
this.lastX = -this.currentX
|
|
@@ -266,7 +251,7 @@
|
|
|
266
251
|
}
|
|
267
252
|
this.lastX = x
|
|
268
253
|
this.lastY = y
|
|
269
|
-
},
|
|
254
|
+
}, 30, {
|
|
270
255
|
leading: true,
|
|
271
256
|
trailing: true
|
|
272
257
|
}))
|
|
@@ -342,7 +327,6 @@
|
|
|
342
327
|
const scrollWrapperHeight = wrapper?.clientHeight || 0
|
|
343
328
|
if (wrapper) {
|
|
344
329
|
const computedStyle = getComputedStyle(wrapper)
|
|
345
|
-
this.refreshVersion = this.refreshVersion + 1
|
|
346
330
|
// 考虑子元素样式可能会设置100%,如果直接继承 scrollContent 的样式可能会有问题
|
|
347
331
|
// 所以使用 wrapper 作为 innerWrapper 的宽高参考依据
|
|
348
332
|
this.$refs.innerWrapper.style.width = `${scrollWrapperWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
|
|
@@ -474,8 +458,7 @@
|
|
|
474
458
|
}
|
|
475
459
|
|
|
476
460
|
const innerWrapper = createElement('div', {
|
|
477
|
-
ref: 'innerWrapper'
|
|
478
|
-
class: 'mpx-inner-wrapper'
|
|
461
|
+
ref: 'innerWrapper'
|
|
479
462
|
}, this.$slots.default)
|
|
480
463
|
|
|
481
464
|
const pullDownContent = this.refresherDefaultStyle !== 'none' ? createElement('div', {
|
|
@@ -585,4 +568,4 @@
|
|
|
585
568
|
background: rgba(255, 255, 255, .7)
|
|
586
569
|
100%
|
|
587
570
|
background: rgba(255, 255, 255, .3)
|
|
588
|
-
</style>
|
|
571
|
+
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.6",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@better-scroll/wheel": "^2.5.1",
|
|
29
29
|
"@better-scroll/zoom": "^2.5.1",
|
|
30
30
|
"@mpxjs/template-engine": "^2.8.7",
|
|
31
|
-
"@mpxjs/utils": "^2.10.
|
|
31
|
+
"@mpxjs/utils": "^2.10.6",
|
|
32
32
|
"acorn": "^8.11.3",
|
|
33
33
|
"acorn-walk": "^7.2.0",
|
|
34
34
|
"async": "^2.6.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@d11/react-native-fast-image": "^8.6.12",
|
|
86
|
-
"@mpxjs/api-proxy": "^2.10.
|
|
86
|
+
"@mpxjs/api-proxy": "^2.10.6",
|
|
87
87
|
"@types/babel-traverse": "^6.25.4",
|
|
88
88
|
"@types/babel-types": "^7.0.4",
|
|
89
89
|
"@types/react": "^18.2.79",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=14.14.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "e28605bc2d8ab33f4dccf13ea98d9ca996f43ed6"
|
|
104
104
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const TAG_NAME = 'sticky-header'
|
|
2
|
-
|
|
3
|
-
module.exports = function ({ print }) {
|
|
4
|
-
return {
|
|
5
|
-
test: TAG_NAME,
|
|
6
|
-
android (tag, { el }) {
|
|
7
|
-
el.isBuiltIn = true
|
|
8
|
-
return 'mpx-sticky-header'
|
|
9
|
-
},
|
|
10
|
-
ios (tag, { el }) {
|
|
11
|
-
el.isBuiltIn = true
|
|
12
|
-
return 'mpx-sticky-header'
|
|
13
|
-
},
|
|
14
|
-
harmony (tag, { el }) {
|
|
15
|
-
el.isBuiltIn = true
|
|
16
|
-
return 'mpx-sticky-header'
|
|
17
|
-
},
|
|
18
|
-
web (tag, { el }) {
|
|
19
|
-
el.isBuiltIn = true
|
|
20
|
-
return 'mpx-sticky-header'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const TAG_NAME = 'sticky-section'
|
|
2
|
-
|
|
3
|
-
module.exports = function ({ print }) {
|
|
4
|
-
return {
|
|
5
|
-
test: TAG_NAME,
|
|
6
|
-
android (tag, { el }) {
|
|
7
|
-
el.isBuiltIn = true
|
|
8
|
-
return 'mpx-sticky-section'
|
|
9
|
-
},
|
|
10
|
-
ios (tag, { el }) {
|
|
11
|
-
el.isBuiltIn = true
|
|
12
|
-
return 'mpx-sticky-section'
|
|
13
|
-
},
|
|
14
|
-
harmony (tag, { el }) {
|
|
15
|
-
el.isBuiltIn = true
|
|
16
|
-
return 'mpx-sticky-section'
|
|
17
|
-
},
|
|
18
|
-
web (tag, { el }) {
|
|
19
|
-
el.isBuiltIn = true
|
|
20
|
-
return 'mpx-sticky-section'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useContext, forwardRef, useMemo, createElement, useId } from 'react';
|
|
2
|
-
import { Animated, StyleSheet, useAnimatedValue } from 'react-native';
|
|
3
|
-
import { ScrollViewContext, StickyContext } from './context';
|
|
4
|
-
import useNodesRef from './useNodesRef';
|
|
5
|
-
import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
|
|
6
|
-
import { error } from '@mpxjs/utils';
|
|
7
|
-
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
8
|
-
const _StickyHeader = forwardRef((stickyHeaderProps = {}, ref) => {
|
|
9
|
-
const { textProps, innerProps: props = {} } = splitProps(stickyHeaderProps);
|
|
10
|
-
const { style, bindstickontopchange, padding = [0, 0, 0, 0], 'offset-top': offsetTop = 0, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
11
|
-
const scrollViewContext = useContext(ScrollViewContext);
|
|
12
|
-
const stickyContext = useContext(StickyContext);
|
|
13
|
-
const { scrollOffset } = scrollViewContext;
|
|
14
|
-
const { registerStickyHeader, unregisterStickyHeader } = stickyContext;
|
|
15
|
-
const headerRef = useRef(null);
|
|
16
|
-
const isStickOnTopRef = useRef(false);
|
|
17
|
-
const id = useId();
|
|
18
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
19
|
-
const { layoutRef, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: headerRef, onLayout });
|
|
20
|
-
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
21
|
-
const headerTopAnimated = useAnimatedValue(0);
|
|
22
|
-
// harmony animatedValue 不支持通过 _value 访问
|
|
23
|
-
const headerTopRef = useRef(0);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
registerStickyHeader({ key: id, updatePosition });
|
|
26
|
-
return () => {
|
|
27
|
-
unregisterStickyHeader(id);
|
|
28
|
-
};
|
|
29
|
-
}, []);
|
|
30
|
-
function updatePosition() {
|
|
31
|
-
if (headerRef.current) {
|
|
32
|
-
const scrollViewRef = scrollViewContext.gestureRef;
|
|
33
|
-
if (scrollViewRef && scrollViewRef.current) {
|
|
34
|
-
headerRef.current.measureLayout(scrollViewRef.current, (left, top) => {
|
|
35
|
-
Animated.timing(headerTopAnimated, {
|
|
36
|
-
toValue: top,
|
|
37
|
-
duration: 0,
|
|
38
|
-
useNativeDriver: true
|
|
39
|
-
}).start();
|
|
40
|
-
headerTopRef.current = top;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
error('StickyHeader measureLayout error: scrollViewRef is not a valid native component reference');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function onLayout(e) {
|
|
49
|
-
updatePosition();
|
|
50
|
-
}
|
|
51
|
-
useNodesRef(props, ref, headerRef, {
|
|
52
|
-
style: normalStyle
|
|
53
|
-
});
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (!bindstickontopchange)
|
|
56
|
-
return;
|
|
57
|
-
const listener = scrollOffset.addListener((state) => {
|
|
58
|
-
const currentScrollValue = state.value;
|
|
59
|
-
const newIsStickOnTop = currentScrollValue > headerTopRef.current;
|
|
60
|
-
if (newIsStickOnTop !== isStickOnTopRef.current) {
|
|
61
|
-
isStickOnTopRef.current = newIsStickOnTop;
|
|
62
|
-
bindstickontopchange(getCustomEvent('stickontopchange', {}, {
|
|
63
|
-
detail: {
|
|
64
|
-
isStickOnTop: newIsStickOnTop
|
|
65
|
-
},
|
|
66
|
-
layoutRef
|
|
67
|
-
}, props));
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return () => {
|
|
71
|
-
scrollOffset.removeListener(listener);
|
|
72
|
-
};
|
|
73
|
-
}, []);
|
|
74
|
-
const animatedStyle = useMemo(() => {
|
|
75
|
-
const translateY = Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
76
|
-
inputRange: [0, 1],
|
|
77
|
-
outputRange: [0, 1],
|
|
78
|
-
extrapolateLeft: 'clamp',
|
|
79
|
-
extrapolateRight: 'extend'
|
|
80
|
-
});
|
|
81
|
-
const finalTranslateY = offsetTop === 0
|
|
82
|
-
? translateY
|
|
83
|
-
: Animated.add(translateY, Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
84
|
-
inputRange: [0, 1],
|
|
85
|
-
outputRange: [0, offsetTop],
|
|
86
|
-
extrapolate: 'clamp'
|
|
87
|
-
}));
|
|
88
|
-
return {
|
|
89
|
-
transform: [{ translateY: finalTranslateY }]
|
|
90
|
-
};
|
|
91
|
-
}, [scrollOffset, headerTopAnimated, offsetTop]);
|
|
92
|
-
const innerProps = useInnerProps(extendObject({}, props, {
|
|
93
|
-
ref: headerRef,
|
|
94
|
-
style: extendObject({}, styles.content, innerStyle, animatedStyle, {
|
|
95
|
-
paddingTop: padding[0] || 0,
|
|
96
|
-
paddingRight: padding[1] || 0,
|
|
97
|
-
paddingBottom: padding[2] || 0,
|
|
98
|
-
paddingLeft: padding[3] || 0
|
|
99
|
-
})
|
|
100
|
-
}, layoutProps), [], { layoutRef });
|
|
101
|
-
return (createElement(Animated.View, innerProps, wrapChildren(props, {
|
|
102
|
-
hasVarDec,
|
|
103
|
-
varContext: varContextRef.current,
|
|
104
|
-
textStyle,
|
|
105
|
-
textProps
|
|
106
|
-
})));
|
|
107
|
-
});
|
|
108
|
-
const styles = StyleSheet.create({
|
|
109
|
-
content: {
|
|
110
|
-
width: '100%',
|
|
111
|
-
zIndex: 10
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
_StickyHeader.displayName = 'MpxStickyHeader';
|
|
115
|
-
export default _StickyHeader;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useRef, forwardRef, createElement, useCallback, useMemo } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import useNodesRef from './useNodesRef';
|
|
4
|
-
import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject } from './utils';
|
|
5
|
-
import { StickyContext } from './context';
|
|
6
|
-
import useInnerProps from './getInnerListeners';
|
|
7
|
-
const _StickySection = forwardRef((stickySectionProps = {}, ref) => {
|
|
8
|
-
const { textProps, innerProps: props = {} } = splitProps(stickySectionProps);
|
|
9
|
-
const { style, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
10
|
-
const sectionRef = useRef(null);
|
|
11
|
-
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
12
|
-
const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: sectionRef, onLayout });
|
|
13
|
-
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
14
|
-
const stickyHeaders = useRef(new Map());
|
|
15
|
-
const registerStickyHeader = useCallback((item) => {
|
|
16
|
-
stickyHeaders.current.set(item.id, item);
|
|
17
|
-
}, []);
|
|
18
|
-
const unregisterStickyHeader = useCallback((id) => {
|
|
19
|
-
stickyHeaders.current.delete(id);
|
|
20
|
-
}, []);
|
|
21
|
-
const contextValue = useMemo(() => ({
|
|
22
|
-
registerStickyHeader,
|
|
23
|
-
unregisterStickyHeader
|
|
24
|
-
}), []);
|
|
25
|
-
useNodesRef(props, ref, sectionRef, {
|
|
26
|
-
style: normalStyle
|
|
27
|
-
});
|
|
28
|
-
function onLayout() {
|
|
29
|
-
stickyHeaders.current.forEach(item => {
|
|
30
|
-
item.updatePosition();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const innerProps = useInnerProps(extendObject({}, props, {
|
|
34
|
-
style: extendObject(innerStyle, layoutStyle),
|
|
35
|
-
ref: sectionRef
|
|
36
|
-
}, layoutProps), [], { layoutRef });
|
|
37
|
-
return (createElement(View, innerProps, createElement(StickyContext.Provider, { value: contextValue }, wrapChildren(props, {
|
|
38
|
-
hasVarDec,
|
|
39
|
-
varContext: varContextRef.current,
|
|
40
|
-
textStyle,
|
|
41
|
-
textProps
|
|
42
|
-
}))));
|
|
43
|
-
});
|
|
44
|
-
_StickySection.displayName = 'MpxStickySection';
|
|
45
|
-
export default _StickySection;
|