@mpxjs/webpack-plugin 2.10.17 → 2.10.18
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/config.js +60 -0
- package/lib/file-loader.js +4 -1
- package/lib/global.d.ts +231 -0
- package/lib/index.js +58 -73
- package/lib/init.js +3 -0
- package/lib/json-compiler/index.js +13 -4
- package/lib/loader.js +4 -0
- package/lib/platform/json/wx/index.js +6 -0
- package/lib/platform/style/wx/index.js +102 -72
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +10 -3
- package/lib/platform/template/wx/component-config/camera.js +13 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +10 -0
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +8 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +19 -2
- package/lib/platform/template/wx/component-config/unsupported.js +9 -0
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/script-helper.js +2 -2
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +17 -7
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
- package/lib/runtime/components/react/context.ts +12 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +181 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
- package/lib/runtime/components/react/dist/context.d.ts +10 -3
- package/lib/runtime/components/react/dist/context.js +1 -2
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +66 -50
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +35 -6
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +84 -78
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +20 -20
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +10 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +95 -61
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +10 -9
- package/lib/runtime/components/react/dist/utils.jsx +47 -24
- package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
- package/lib/runtime/components/react/mpx-image.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +77 -54
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
- package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +115 -60
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +51 -27
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +1 -2
- package/lib/style-compiler/strip-conditional.js +243 -0
- package/lib/template-compiler/compiler.js +2 -5
- package/lib/utils/string.js +25 -1
- package/lib/wxss/loader.js +4 -1
- package/lib/wxss/utils.js +7 -2
- package/package.json +7 -14
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
- package/lib/style-compiler/strip-conditional-loader.js +0 -289
|
@@ -112,6 +112,11 @@ type ScrollAdditionalProps = {
|
|
|
112
112
|
|
|
113
113
|
const AnimatedScrollView = RNAnimated.createAnimatedComponent(ScrollView) as React.ComponentType<any>
|
|
114
114
|
|
|
115
|
+
const REFRESH_COLOR = {
|
|
116
|
+
black: ['#000'],
|
|
117
|
+
white: ['#fff']
|
|
118
|
+
}
|
|
119
|
+
|
|
115
120
|
const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, ScrollViewProps>((scrollViewProps: ScrollViewProps = {}, ref): JSX.Element => {
|
|
116
121
|
const { textProps, innerProps: props = {} } = splitProps(scrollViewProps)
|
|
117
122
|
const {
|
|
@@ -121,9 +126,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
121
126
|
binddragstart,
|
|
122
127
|
binddragging,
|
|
123
128
|
binddragend,
|
|
124
|
-
bindtouchstart,
|
|
125
129
|
bindtouchmove,
|
|
126
|
-
bindtouchend,
|
|
127
130
|
'scroll-x': scrollX = false,
|
|
128
131
|
'scroll-y': scrollY = false,
|
|
129
132
|
'enable-back-to-top': enableBackToTop = false,
|
|
@@ -159,14 +162,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
159
162
|
const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
|
|
160
163
|
const waitForHandlers = flatGesture(waitFor)
|
|
161
164
|
|
|
162
|
-
const
|
|
165
|
+
const { refresherContent, otherContent } = getRefresherContent(props.children)
|
|
166
|
+
const hasRefresher = refresherContent && refresherEnabled
|
|
163
167
|
|
|
168
|
+
const [refreshing, setRefreshing] = useState(false)
|
|
164
169
|
const [enableScroll, setEnableScroll] = useState(true)
|
|
165
|
-
const enableScrollValue = useSharedValue(true)
|
|
166
|
-
|
|
167
170
|
const [scrollBounces, setScrollBounces] = useState(false)
|
|
168
|
-
const bouncesValue = useSharedValue(!!false)
|
|
169
171
|
|
|
172
|
+
const enableScrollValue = useSharedValue(true)
|
|
173
|
+
const bouncesValue = useSharedValue(false)
|
|
170
174
|
const translateY = useSharedValue(0)
|
|
171
175
|
const isAtTop = useSharedValue(true)
|
|
172
176
|
const refresherHeight = useSharedValue(0)
|
|
@@ -186,16 +190,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
186
190
|
|
|
187
191
|
const firstScrollIntoViewChange = useRef<boolean>(true)
|
|
188
192
|
|
|
189
|
-
const refreshColor = {
|
|
190
|
-
black: ['#000'],
|
|
191
|
-
white: ['#fff']
|
|
192
|
-
}
|
|
193
|
-
|
|
194
193
|
const isContentSizeChange = useRef(false)
|
|
195
194
|
|
|
196
|
-
const { refresherContent, otherContent } = getRefresherContent(props.children)
|
|
197
|
-
const hasRefresher = refresherContent && refresherEnabled
|
|
198
|
-
|
|
199
195
|
const {
|
|
200
196
|
normalStyle,
|
|
201
197
|
hasVarDec,
|
|
@@ -643,67 +639,71 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
643
639
|
}
|
|
644
640
|
}
|
|
645
641
|
|
|
646
|
-
// 处理下拉刷新的手势
|
|
647
|
-
const panGesture =
|
|
648
|
-
.
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
642
|
+
// 处理下拉刷新的手势 - 使用 useMemo 避免每次渲染都创建
|
|
643
|
+
const panGesture = useMemo(() => {
|
|
644
|
+
if (!hasRefresher) return Gesture.Pan() // 返回空手势
|
|
645
|
+
|
|
646
|
+
return Gesture.Pan()
|
|
647
|
+
.onUpdate((event) => {
|
|
648
|
+
'worklet'
|
|
649
|
+
if (enhanced && !!bounces) {
|
|
650
|
+
if (event.translationY > 0 && bouncesValue.value) {
|
|
651
|
+
updateBouncesState(false)
|
|
652
|
+
} else if ((event.translationY < 0) && !bouncesValue.value) {
|
|
653
|
+
updateBouncesState(true)
|
|
654
|
+
}
|
|
655
655
|
}
|
|
656
|
-
}
|
|
657
656
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
657
|
+
if (translateY.value <= 0 && event.translationY < 0) {
|
|
658
|
+
// 滑动到顶再向上开启滚动
|
|
659
|
+
updateScrollState(true)
|
|
660
|
+
} else if (event.translationY > 0 && isAtTop.value) {
|
|
661
|
+
// 滚动到顶再向下禁止滚动
|
|
662
|
+
updateScrollState(false)
|
|
663
|
+
}
|
|
664
|
+
// 禁止滚动后切换为滑动
|
|
665
|
+
if (!enableScrollValue.value && isAtTop.value) {
|
|
666
|
+
if (refreshing) {
|
|
667
|
+
// 从完全展开状态(refresherHeight.value)开始计算偏移
|
|
668
|
+
translateY.value = Math.max(
|
|
669
|
+
0,
|
|
670
|
+
Math.min(
|
|
671
|
+
refresherHeight.value,
|
|
672
|
+
refresherHeight.value + event.translationY
|
|
673
|
+
)
|
|
674
674
|
)
|
|
675
|
-
)
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
675
|
+
} else if (event.translationY > 0) {
|
|
676
|
+
// 非刷新状态下的下拉逻辑保持不变
|
|
677
|
+
translateY.value = Math.min(event.translationY * 0.6, refresherHeight.value)
|
|
678
|
+
}
|
|
679
679
|
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
680
|
+
})
|
|
681
|
+
.onEnd((event) => {
|
|
682
|
+
'worklet'
|
|
683
|
+
if (enableScrollValue.value) return
|
|
684
|
+
if (refreshing) {
|
|
685
|
+
// 刷新状态下,根据滑动距离决定是否隐藏
|
|
686
|
+
// 如果向下滑动没超过 refresherThreshold,就完全隐藏,如果向上滑动完全隐藏
|
|
687
|
+
if ((event.translationY > 0 && translateY.value < refresherThreshold) || event.translationY < 0) {
|
|
688
|
+
translateY.value = withTiming(0)
|
|
689
|
+
updateScrollState(true)
|
|
690
|
+
runOnJS(runOnJSCallback)('setRefreshing', false)
|
|
691
|
+
} else {
|
|
692
|
+
translateY.value = withTiming(refresherHeight.value)
|
|
693
|
+
}
|
|
694
|
+
} else if (event.translationY >= refresherHeight.value) {
|
|
695
|
+
// 触发刷新
|
|
696
|
+
translateY.value = withTiming(refresherHeight.value)
|
|
697
|
+
runOnJS(runOnJSCallback)('onRefresh')
|
|
698
|
+
} else {
|
|
699
|
+
// 回弹
|
|
689
700
|
translateY.value = withTiming(0)
|
|
690
701
|
updateScrollState(true)
|
|
691
702
|
runOnJS(runOnJSCallback)('setRefreshing', false)
|
|
692
|
-
} else {
|
|
693
|
-
translateY.value = withTiming(refresherHeight.value)
|
|
694
703
|
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
runOnJS(runOnJSCallback)('onRefresh')
|
|
699
|
-
} else {
|
|
700
|
-
// 回弹
|
|
701
|
-
translateY.value = withTiming(0)
|
|
702
|
-
updateScrollState(true)
|
|
703
|
-
runOnJS(runOnJSCallback)('setRefreshing', false)
|
|
704
|
-
}
|
|
705
|
-
})
|
|
706
|
-
.simultaneousWithExternalGesture(scrollViewRef)
|
|
704
|
+
})
|
|
705
|
+
.simultaneousWithExternalGesture(scrollViewRef)
|
|
706
|
+
}, [hasRefresher, enhanced, bounces, refreshing, refresherThreshold])
|
|
707
707
|
|
|
708
708
|
const scrollAdditionalProps: ScrollAdditionalProps = extendObject(
|
|
709
709
|
{
|
|
@@ -779,61 +779,57 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
779
779
|
|
|
780
780
|
const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView
|
|
781
781
|
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
782
|
+
const createScrollViewContent = () => {
|
|
783
|
+
const wrappedChildren = wrapChildren(hasRefresher ? extendObject({}, props, { children: otherContent }) : props,
|
|
784
|
+
{
|
|
785
|
+
hasVarDec,
|
|
786
|
+
varContext: varContextRef.current,
|
|
787
|
+
textStyle,
|
|
788
|
+
textProps
|
|
789
|
+
})
|
|
790
|
+
return createElement(ScrollViewContext.Provider, { value: contextValue }, wrappedChildren)
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
const withRefresherScrollView = () => {
|
|
794
|
+
return createElement(
|
|
795
|
+
GestureDetector,
|
|
796
|
+
{ gesture: panGesture },
|
|
793
797
|
createElement(
|
|
794
|
-
|
|
795
|
-
|
|
798
|
+
ScrollViewComponent,
|
|
799
|
+
innerProps,
|
|
800
|
+
createElement(
|
|
801
|
+
Animated.View,
|
|
802
|
+
{ style: [refresherAnimatedStyle, refresherLayoutStyle], onLayout: onRefresherLayout },
|
|
803
|
+
refresherContent
|
|
804
|
+
),
|
|
796
805
|
createElement(
|
|
797
|
-
|
|
798
|
-
{
|
|
799
|
-
|
|
800
|
-
extendObject({}, props, { children: otherContent }),
|
|
801
|
-
{
|
|
802
|
-
hasVarDec,
|
|
803
|
-
varContext: varContextRef.current,
|
|
804
|
-
textStyle,
|
|
805
|
-
textProps
|
|
806
|
-
}
|
|
807
|
-
)
|
|
806
|
+
Animated.View,
|
|
807
|
+
{ style: contentAnimatedStyle },
|
|
808
|
+
createScrollViewContent()
|
|
808
809
|
)
|
|
809
810
|
)
|
|
810
811
|
)
|
|
811
|
-
|
|
812
|
+
}
|
|
812
813
|
|
|
813
|
-
const commonScrollView =
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
hasVarDec,
|
|
829
|
-
varContext: varContextRef.current,
|
|
830
|
-
textStyle,
|
|
831
|
-
textProps
|
|
832
|
-
})
|
|
814
|
+
const commonScrollView = () => {
|
|
815
|
+
const refreshControl = refresherEnabled
|
|
816
|
+
? createElement(RefreshControl, extendObject({
|
|
817
|
+
progressBackgroundColor: refresherBackground,
|
|
818
|
+
refreshing: refreshing,
|
|
819
|
+
onRefresh: onRefresh
|
|
820
|
+
}, refresherDefaultStyle && refresherDefaultStyle !== 'none'
|
|
821
|
+
? { colors: REFRESH_COLOR[refresherDefaultStyle] }
|
|
822
|
+
: {}))
|
|
823
|
+
: undefined
|
|
824
|
+
|
|
825
|
+
return createElement(
|
|
826
|
+
ScrollViewComponent,
|
|
827
|
+
extendObject({}, innerProps, { refreshControl }),
|
|
828
|
+
createScrollViewContent()
|
|
833
829
|
)
|
|
834
|
-
|
|
830
|
+
}
|
|
835
831
|
|
|
836
|
-
let scrollViewComponent = hasRefresher ? withRefresherScrollView : commonScrollView
|
|
832
|
+
let scrollViewComponent = hasRefresher ? withRefresherScrollView() : commonScrollView()
|
|
837
833
|
|
|
838
834
|
if (hasPositionFixed) {
|
|
839
835
|
scrollViewComponent = createElement(Portal, null, scrollViewComponent)
|
|
@@ -33,9 +33,8 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
|
|
|
33
33
|
'parent-height': parentHeight
|
|
34
34
|
} = props
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const { scrollOffset, gestureRef: scrollViewRef } = useContext(ScrollViewContext)
|
|
37
37
|
const stickyContext = useContext(StickyContext)
|
|
38
|
-
const { scrollOffset } = scrollViewContext
|
|
39
38
|
const { registerStickyHeader, unregisterStickyHeader } = stickyContext
|
|
40
39
|
const headerRef = useRef<View>(null)
|
|
41
40
|
const isStickOnTopRef = useRef(false)
|
|
@@ -67,7 +66,6 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
|
|
|
67
66
|
|
|
68
67
|
function updatePosition () {
|
|
69
68
|
if (headerRef.current) {
|
|
70
|
-
const scrollViewRef = scrollViewContext.gestureRef
|
|
71
69
|
if (scrollViewRef && scrollViewRef.current) {
|
|
72
70
|
headerRef.current.measureLayout(
|
|
73
71
|
scrollViewRef.current,
|
|
@@ -95,7 +93,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
|
|
|
95
93
|
})
|
|
96
94
|
|
|
97
95
|
useEffect(() => {
|
|
98
|
-
if (!bindstickontopchange) return
|
|
96
|
+
if (!bindstickontopchange || !scrollOffset) return
|
|
99
97
|
|
|
100
98
|
const listener = scrollOffset.addListener((state: { value: number }) => {
|
|
101
99
|
const currentScrollValue = state.value
|
|
@@ -115,29 +113,31 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
|
|
|
115
113
|
return () => {
|
|
116
114
|
scrollOffset.removeListener(listener)
|
|
117
115
|
}
|
|
118
|
-
}, [])
|
|
116
|
+
}, [bindstickontopchange, scrollOffset])
|
|
119
117
|
|
|
120
118
|
const animatedStyle = useMemo(() => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
if (scrollOffset) {
|
|
120
|
+
const translateY = Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
121
|
+
inputRange: [0, 1],
|
|
122
|
+
outputRange: [0, 1],
|
|
123
|
+
extrapolateLeft: 'clamp',
|
|
124
|
+
extrapolateRight: 'extend'
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const finalTranslateY = offsetTop === 0
|
|
128
|
+
? translateY
|
|
129
|
+
: Animated.add(
|
|
130
|
+
translateY,
|
|
131
|
+
Animated.subtract(scrollOffset, headerTopAnimated).interpolate({
|
|
132
|
+
inputRange: [0, 1],
|
|
133
|
+
outputRange: [0, offsetTop],
|
|
134
|
+
extrapolate: 'clamp'
|
|
135
|
+
})
|
|
136
|
+
)
|
|
138
137
|
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
return {
|
|
139
|
+
transform: [{ translateY: finalTranslateY }]
|
|
140
|
+
}
|
|
141
141
|
}
|
|
142
142
|
}, [scrollOffset, headerTopAnimated, offsetTop])
|
|
143
143
|
|