@mpxjs/webpack-plugin 2.10.7-beta.8 → 2.10.7

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.
Files changed (35) hide show
  1. package/LICENSE +433 -0
  2. package/lib/dependencies/RecordPageConfigsMapDependency.js +1 -1
  3. package/lib/index.js +5 -6
  4. package/lib/platform/template/wx/component-config/index.js +1 -5
  5. package/lib/platform/template/wx/index.js +2 -1
  6. package/lib/runtime/components/react/context.ts +3 -12
  7. package/lib/runtime/components/react/dist/context.js +1 -4
  8. package/lib/runtime/components/react/dist/getInnerListeners.js +1 -1
  9. package/lib/runtime/components/react/dist/mpx-button.jsx +2 -2
  10. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +2 -2
  11. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -17
  12. package/lib/runtime/components/react/dist/mpx-swiper.jsx +27 -53
  13. package/lib/runtime/components/react/dist/mpx-web-view.jsx +14 -28
  14. package/lib/runtime/components/react/dist/useAnimationHooks.js +2 -87
  15. package/lib/runtime/components/react/getInnerListeners.ts +1 -1
  16. package/lib/runtime/components/react/mpx-button.tsx +2 -3
  17. package/lib/runtime/components/react/mpx-movable-view.tsx +2 -2
  18. package/lib/runtime/components/react/mpx-scroll-view.tsx +50 -68
  19. package/lib/runtime/components/react/mpx-swiper.tsx +25 -53
  20. package/lib/runtime/components/react/mpx-web-view.tsx +13 -33
  21. package/lib/runtime/components/react/types/global.d.ts +15 -0
  22. package/lib/runtime/components/react/useAnimationHooks.ts +2 -85
  23. package/lib/runtime/components/web/mpx-scroll-view.vue +4 -21
  24. package/lib/template-compiler/compiler.js +1 -1
  25. package/package.json +4 -4
  26. package/lib/platform/template/wx/component-config/sticky-header.js +0 -23
  27. package/lib/platform/template/wx/component-config/sticky-section.js +0 -23
  28. package/lib/runtime/components/react/AsyncContainer.tsx +0 -189
  29. package/lib/runtime/components/react/dist/AsyncContainer.jsx +0 -141
  30. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +0 -115
  31. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +0 -45
  32. package/lib/runtime/components/react/mpx-sticky-header.tsx +0 -179
  33. package/lib/runtime/components/react/mpx-sticky-section.tsx +0 -96
  34. package/lib/runtime/components/web/mpx-sticky-header.vue +0 -91
  35. package/lib/runtime/components/web/mpx-sticky-section.vue +0 -15
@@ -125,10 +125,6 @@ const SwiperWrapper = forwardRef((props, ref) => {
125
125
  const moveTranstion = useSharedValue(0);
126
126
  // 记录从onBegin 到 onTouchesUp 的时间
127
127
  const moveTime = useSharedValue(0);
128
- // 记录从onBegin 到 onTouchesCancelled 另外一个方向移动的距离
129
- const anotherDirectionMove = useSharedValue(0);
130
- // 另一个方向的
131
- const anotherAbso = 'absolute' + (dir === 'x' ? 'y' : 'x').toUpperCase();
132
128
  const timerId = useRef(0);
133
129
  const intervalTimer = props.interval || 500;
134
130
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
@@ -409,11 +405,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
409
405
  }
410
406
  }, [children.length]);
411
407
  useEffect(() => {
412
- // 1. 如果用户在touch的过程中, 外部更新了current以外部为准(小程序表现)
413
- // 2. 手指滑动过程中更新索引,外部会把current再穿进来,导致offset直接更新了
414
- if (props.current !== currentIndex.value) {
415
- updateCurrent(props.current || 0, step.value);
416
- }
408
+ updateCurrent(props.current || 0, step.value);
417
409
  }, [props.current]);
418
410
  useEffect(() => {
419
411
  autoplayShared.value = autoplay;
@@ -476,26 +468,20 @@ const SwiperWrapper = forwardRef((props, ref) => {
476
468
  targetOffset: -moveToTargetPos
477
469
  };
478
470
  }
479
- function checkUnCircular(eventData) {
471
+ function canMove(eventData) {
480
472
  'worklet';
481
473
  const { translation } = eventData;
482
474
  const currentOffset = Math.abs(offset.value);
483
- // 向右滑动swiper
484
- if (translation < 0) {
485
- const boundaryOffset = step.value * (childrenLength.value - 1);
486
- const gestureMovePos = Math.abs(translation) + currentOffset;
487
- return {
488
- // 防止快速连续向右滑动时,手势移动的距离 当前的offset超出边界
489
- targetOffset: gestureMovePos > boundaryOffset ? -boundaryOffset : offset.value + translation,
490
- canMove: currentOffset < boundaryOffset
491
- };
475
+ if (!circularShared.value) {
476
+ if (translation < 0) {
477
+ return currentOffset < step.value * (childrenLength.value - 1);
478
+ }
479
+ else {
480
+ return currentOffset > 0;
481
+ }
492
482
  }
493
483
  else {
494
- const gestureMovePos = currentOffset - translation;
495
- return {
496
- targetOffset: gestureMovePos < 0 ? 0 : offset.value + translation,
497
- canMove: currentOffset > 0
498
- };
484
+ return true;
499
485
  }
500
486
  }
501
487
  function handleEnd(eventData) {
@@ -555,7 +541,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
555
541
  }
556
542
  });
557
543
  }
558
- function computeHalf() {
544
+ function handleLongPress() {
559
545
  'worklet';
560
546
  const currentOffset = Math.abs(offset.value);
561
547
  let preOffset = (currentIndex.value + patchElmNumShared.value) * step.value;
@@ -565,14 +551,6 @@ const SwiperWrapper = forwardRef((props, ref) => {
565
551
  // 正常事件中拿到的transition值(正向滑动<0,倒着滑>0)
566
552
  const diffOffset = preOffset - currentOffset;
567
553
  const half = Math.abs(diffOffset) > step.value / 2;
568
- return {
569
- diffOffset,
570
- half
571
- };
572
- }
573
- function handleLongPress() {
574
- 'worklet';
575
- const { diffOffset, half } = computeHalf();
576
554
  if (+diffOffset === 0) {
577
555
  runOnJS(resumeLoop)();
578
556
  }
@@ -632,30 +610,19 @@ const SwiperWrapper = forwardRef((props, ref) => {
632
610
  runOnJS(pauseLoop)();
633
611
  preAbsolutePos.value = e[strAbso];
634
612
  moveTranstion.value = e[strAbso];
635
- anotherDirectionMove.value = e[anotherAbso];
636
613
  moveTime.value = new Date().getTime();
637
614
  })
638
- .onUpdate((e) => {
615
+ .onTouchesMove((e) => {
639
616
  'worklet';
640
617
  if (touchfinish.value)
641
618
  return;
642
- const moveDistance = e[strAbso] - preAbsolutePos.value;
619
+ const touchEventData = e.changedTouches[0];
620
+ const moveDistance = touchEventData[strAbso] - preAbsolutePos.value;
643
621
  const eventData = {
644
622
  translation: moveDistance
645
623
  };
646
- // 1. 在Move过程中,如果手指一直没抬起来,超过一半的话也会更新索引
647
- const { half } = computeHalf();
648
- if (half) {
649
- const { selectedIndex } = getTargetPosition(eventData);
650
- currentIndex.value = selectedIndex;
651
- }
652
- // 2. 处理用户一直拖拽到临界点的场景, 不会执行onEnd
653
- const { canMove, targetOffset } = checkUnCircular(eventData);
654
- if (!circularShared.value) {
655
- if (canMove) {
656
- offset.value = targetOffset;
657
- preAbsolutePos.value = e[strAbso];
658
- }
624
+ // 处理用户一直拖拽到临界点的场景, 不会执行onEnd
625
+ if (!circularShared.value && !canMove(eventData)) {
659
626
  return;
660
627
  }
661
628
  const { isBoundary, resetOffset } = reachBoundary(eventData);
@@ -665,23 +632,30 @@ const SwiperWrapper = forwardRef((props, ref) => {
665
632
  else {
666
633
  offset.value = moveDistance + offset.value;
667
634
  }
668
- preAbsolutePos.value = e[strAbso];
635
+ preAbsolutePos.value = touchEventData[strAbso];
669
636
  })
670
- .onFinalize((e) => {
637
+ .onTouchesUp((e) => {
671
638
  'worklet';
672
639
  if (touchfinish.value)
673
640
  return;
674
- const moveDistance = e[strAbso] - moveTranstion.value;
641
+ const touchEventData = e.changedTouches[0];
642
+ const moveDistance = touchEventData[strAbso] - moveTranstion.value;
675
643
  touchfinish.value = true;
676
644
  const eventData = {
677
645
  translation: moveDistance
678
646
  };
647
+ if (childrenLength.value === 1) {
648
+ return handleBackInit();
649
+ }
650
+ // 用户手指按下起来, 需要计算正确的位置, 比如在滑动过程中突然按下然后起来,需要计算到正确的位置
651
+ if (!circularShared.value && !canMove(eventData)) {
652
+ return;
653
+ }
679
654
  const strVelocity = moveDistance / (new Date().getTime() - moveTime.value) * 1000;
680
655
  if (Math.abs(strVelocity) < longPressRatio) {
681
656
  handleLongPress();
682
657
  }
683
658
  else {
684
- // 如果触发了onTouchesCancelled,不会触发onUpdate不会更新offset值, 索引不会变更
685
659
  handleEnd(eventData);
686
660
  }
687
661
  })
@@ -1,6 +1,7 @@
1
1
  import { forwardRef, useRef, useContext, useMemo, useState } from 'react';
2
2
  import { warn, isFunction } from '@mpxjs/utils';
3
3
  import Portal from './mpx-portal/index';
4
+ import { usePreventRemove } from '@react-navigation/native';
4
5
  import { getCustomEvent } from './getInnerListeners';
5
6
  import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy';
6
7
  import { WebView } from 'react-native-webview';
@@ -55,8 +56,8 @@ const _WebView = forwardRef((props, ref) => {
55
56
  const webViewRef = useRef(null);
56
57
  const fristLoaded = useRef(false);
57
58
  const isLoadError = useRef(false);
59
+ const isNavigateBack = useRef(false);
58
60
  const statusCode = useRef('');
59
- const [isLoaded, setIsLoaded] = useState(true);
60
61
  const defaultWebViewStyle = {
61
62
  position: 'absolute',
62
63
  left: 0,
@@ -64,27 +65,18 @@ const _WebView = forwardRef((props, ref) => {
64
65
  top: 0,
65
66
  bottom: 0
66
67
  };
67
- const canGoBack = useRef(false);
68
- const isNavigateBack = useRef(false);
69
- const beforeRemoveHandle = (e) => {
70
- if (canGoBack.current && !isNavigateBack.current) {
68
+ const navigation = useNavigation();
69
+ const [isIntercept, setIsIntercept] = useState(false);
70
+ usePreventRemove(isIntercept, (event) => {
71
+ const { data } = event;
72
+ if (isNavigateBack.current) {
73
+ navigation?.dispatch(data.action);
74
+ }
75
+ else {
71
76
  webViewRef.current?.goBack();
72
- e.preventDefault();
73
77
  }
74
78
  isNavigateBack.current = false;
75
- };
76
- const navigation = useNavigation();
77
- // useEffect(() => {
78
- // let beforeRemoveSubscription:any
79
- // if (__mpx_mode__ !== 'ios') {
80
- // beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
81
- // }
82
- // return () => {
83
- // if (isFunction(beforeRemoveSubscription)) {
84
- // beforeRemoveSubscription()
85
- // }
86
- // }
87
- // }, [])
79
+ });
88
80
  useNodesRef(props, ref, webViewRef, {
89
81
  style: defaultWebViewStyle
90
82
  });
@@ -131,13 +123,13 @@ const _WebView = forwardRef((props, ref) => {
131
123
  };
132
124
  const _changeUrl = function (navState) {
133
125
  if (navState.navigationType) { // navigationType这个事件在页面开始加载时和页面加载完成时都会被触发所以判断这个避免其他无效触发执行该逻辑
134
- canGoBack.current = navState.canGoBack;
135
126
  currentPage.__webViewUrl = navState.url;
127
+ setIsIntercept(navState.canGoBack);
136
128
  }
137
129
  };
138
130
  const _onLoadProgress = function (event) {
139
131
  if (__mpx_mode__ !== 'ios') {
140
- canGoBack.current = event.nativeEvent.canGoBack;
132
+ setIsIntercept(event.nativeEvent.canGoBack);
141
133
  }
142
134
  };
143
135
  const _message = function (res) {
@@ -227,7 +219,6 @@ const _WebView = forwardRef((props, ref) => {
227
219
  };
228
220
  const onLoadEndHandle = function (res) {
229
221
  fristLoaded.current = true;
230
- setIsLoaded(true);
231
222
  const src = res.nativeEvent?.url;
232
223
  if (isLoadError.current) {
233
224
  isLoadError.current = false;
@@ -275,18 +266,13 @@ const _WebView = forwardRef((props, ref) => {
275
266
  setPageLoadErr(true);
276
267
  }
277
268
  };
278
- const onLoadStart = function () {
279
- if (!fristLoaded.current) {
280
- setIsLoaded(false);
281
- }
282
- };
283
269
  return (<Portal>
284
270
  {pageLoadErr
285
271
  ? (<View style={[styles.loadErrorContext, defaultWebViewStyle]}>
286
272
  <View style={styles.loadErrorText}><Text style={{ fontSize: 14, color: '#999999' }}>{currentErrorText.text}</Text></View>
287
273
  <View style={styles.loadErrorButton} onTouchEnd={_reload}><Text style={{ fontSize: 12, color: '#666666' }}>{currentErrorText.button}</Text></View>
288
274
  </View>)
289
- : (<WebView style={defaultWebViewStyle} pointerEvents={isLoaded ? 'auto' : 'none'} source={{ uri: src }} ref={webViewRef} javaScriptEnabled={true} onNavigationStateChange={_changeUrl} onMessage={_message} injectedJavaScript={injectedJavaScript} onLoadProgress={_onLoadProgress} onLoadEnd={onLoadEnd} onHttpError={onHttpError} onError={onError} onLoadStart={onLoadStart} allowsBackForwardNavigationGestures={true}></WebView>)}
275
+ : (<WebView style={defaultWebViewStyle} source={{ uri: src }} ref={webViewRef} javaScriptEnabled={true} onNavigationStateChange={_changeUrl} onMessage={_message} injectedJavaScript={injectedJavaScript} onLoadProgress={_onLoadProgress} onLoadEnd={onLoadEnd} onHttpError={onHttpError} onError={onError} allowsBackForwardNavigationGestures={true}></WebView>)}
290
276
  </Portal>);
291
277
  });
292
278
  _WebView.displayName = 'MpxWebview';
@@ -48,90 +48,6 @@ const InitialValue = Object.assign({
48
48
  const TransformOrigin = 'transformOrigin';
49
49
  // transform
50
50
  const isTransform = (key) => Object.keys(TransformInitial).includes(key);
51
- // 多value解析
52
- const parseValues = (str, char = ' ') => {
53
- let stack = 0;
54
- let temp = '';
55
- const result = [];
56
- for (let i = 0; i < str.length; i++) {
57
- if (str[i] === '(') {
58
- stack++;
59
- }
60
- else if (str[i] === ')') {
61
- stack--;
62
- }
63
- // 非括号内 或者 非分隔字符且非空
64
- if (stack !== 0 || (str[i] !== char && str[i] !== ' ')) {
65
- temp += str[i];
66
- }
67
- if ((stack === 0 && str[i] === char) || i === str.length - 1) {
68
- result.push(temp);
69
- temp = '';
70
- }
71
- }
72
- return result;
73
- };
74
- // parse string transform, eg: transform: 'rotateX(45deg) rotateZ(0.785398rad)'
75
- const parseTransform = (transformStr) => {
76
- const values = parseValues(transformStr);
77
- const transform = [];
78
- values.forEach(item => {
79
- const match = item.match(/([/\w]+)\((.+)\)/);
80
- if (match && match.length >= 3) {
81
- let key = match[1];
82
- const val = match[2];
83
- switch (key) {
84
- case 'translateX':
85
- case 'translateY':
86
- case 'scaleX':
87
- case 'scaleY':
88
- case 'rotateX':
89
- case 'rotateY':
90
- case 'rotateZ':
91
- case 'rotate':
92
- case 'skewX':
93
- case 'skewY':
94
- case 'perspective':
95
- // rotate 处理成 rotateZ
96
- key = key === 'rotate' ? 'rotateZ' : key;
97
- // 单个值处理
98
- transform.push({ [key]: global.__formatValue(val) });
99
- break;
100
- case 'matrix':
101
- transform.push({ [key]: parseValues(val, ',').map(val => +val) });
102
- break;
103
- case 'translate':
104
- case 'scale':
105
- case 'skew':
106
- case 'translate3d': // x y 支持 z不支持
107
- case 'scale3d': // x y 支持 z不支持
108
- {
109
- // 2 个以上的值处理
110
- key = key.replace('3d', '');
111
- const vals = parseValues(val, ',').splice(0, 3);
112
- // scale(.5) === scaleX(.5) scaleY(.5)
113
- if (vals.length === 1 && key === 'scale') {
114
- vals.push(vals[0]);
115
- }
116
- const xyz = ['X', 'Y', 'Z'];
117
- transform.push(...vals.map((v, index) => {
118
- return { [`${key}${xyz[index] || ''}`]: global.__formatValue(v.trim()) };
119
- }));
120
- break;
121
- }
122
- }
123
- }
124
- });
125
- return transform;
126
- };
127
- // format style
128
- const formatStyle = (style) => {
129
- if (!style.transform || Array.isArray(style.transform))
130
- return style;
131
- return Object.assign({}, style, {
132
- transform: parseTransform(style.transform)
133
- });
134
- };
135
51
  // transform 数组转对象
136
52
  function getTransformObj(transforms) {
137
53
  'worklet';
@@ -140,7 +56,7 @@ function getTransformObj(transforms) {
140
56
  }, {});
141
57
  }
142
58
  export default function useAnimationHooks(props) {
143
- const { style = {}, animation, enableAnimation, transitionend, layoutRef } = props;
59
+ const { style: originalStyle = {}, animation, enableAnimation, transitionend, layoutRef } = props;
144
60
  const enableStyleAnimation = enableAnimation || !!animation;
145
61
  const enableAnimationRef = useRef(enableStyleAnimation);
146
62
  if (enableAnimationRef.current !== enableStyleAnimation) {
@@ -148,7 +64,6 @@ export default function useAnimationHooks(props) {
148
64
  }
149
65
  if (!enableAnimationRef.current)
150
66
  return { enableStyleAnimation: false };
151
- const originalStyle = formatStyle(style);
152
67
  // id 标识
153
68
  const id = animation?.id || -1;
154
69
  // 有动画样式的 style key
@@ -177,7 +92,7 @@ export default function useAnimationHooks(props) {
177
92
  useEffect(() => {
178
93
  // style 更新后同步更新 lastStyleRef & shareValMap
179
94
  updateStyleVal();
180
- }, [style]);
95
+ }, [originalStyle]);
181
96
  // ** 获取动画样式prop & 驱动动画
182
97
  // eslint-disable-next-line react-hooks/rules-of-hooks
183
98
  useEffect(() => {
@@ -24,7 +24,7 @@ const getTouchEvent = (
24
24
  ) => {
25
25
  const { navigation, propsRef, layoutRef } = config
26
26
  const props = propsRef.current
27
- const { y: navigationY = 0 } = navigation?.layout || {}
27
+ const { top: navigationY = 0 } = navigation?.layout || {}
28
28
  const nativeEvent = event.nativeEvent
29
29
  const { timestamp, pageX, pageY, touches, changedTouches } = nativeEvent
30
30
  const { id } = props
@@ -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 = useAnimatedValue(0)
160
+ const image = useRef(new Animated.Value(0)).current
162
161
 
163
162
  const rotate = image.interpolate({
164
163
  inputRange: [0, 1],
@@ -340,7 +340,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
340
340
  setHeight(height || 0)
341
341
  }
342
342
  nodeRef.current?.measure((x: number, y: number, width: number, height: number) => {
343
- const { y: navigationY = 0 } = navigation?.layout || {}
343
+ const { top: navigationY = 0 } = navigation?.layout || {}
344
344
  layoutRef.current = { x, y: y - navigationY, width, height, offsetLeft: 0, offsetTop: 0 }
345
345
  resetBoundaryAndCheck({ width, height })
346
346
  })
@@ -348,7 +348,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
348
348
  }
349
349
 
350
350
  const extendEvent = useCallback((e: any, type: 'start' | 'move' | 'end') => {
351
- const { y: navigationY = 0 } = navigation?.layout || {}
351
+ const { top: navigationY = 0 } = navigation?.layout || {}
352
352
  const touchArr = [e.changedTouches, e.allTouches]
353
353
  touchArr.forEach(touches => {
354
354
  touches && touches.forEach((item: { absoluteX: number; absoluteY: number; pageX: number; pageY: number; clientX: number; clientY: number }) => {
@@ -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, Animated as RNAnimated } from 'react-native'
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
- 'scroll-x'?: boolean;
51
- 'scroll-y'?: boolean;
52
- 'enable-back-to-top'?: boolean;
53
- 'show-scrollbar'?: boolean;
54
- 'paging-enabled'?: boolean;
55
- 'upper-threshold'?: number;
56
- 'lower-threshold'?: number;
57
- 'scroll-with-animation'?: boolean;
58
- 'refresher-triggered'?: boolean;
59
- 'refresher-enabled'?: boolean;
60
- 'refresher-default-style'?: 'black' | 'white' | 'none';
61
- 'refresher-background'?: string;
62
- 'refresher-threshold'?: number;
63
- 'scroll-top'?: number;
64
- 'scroll-left'?: number;
65
- 'enable-offset'?: boolean;
66
- 'scroll-into-view'?: string;
67
- 'enable-trigger-intersection-observer'?: boolean;
68
- 'enable-var'?: boolean;
69
- 'external-var-context'?: Record<string, any>;
70
- 'parent-font-size'?: number;
71
- 'parent-width'?: number;
72
- 'parent-height'?: number;
73
- 'enable-sticky'?: boolean;
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: enableSticky ? scrollHandler : 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
- ScrollViewComponent,
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
- ScrollViewComponent,
770
- extendObject({}, innerProps, {
751
+ ScrollView,
752
+ extendObject(innerProps, {
771
753
  refreshControl: refresherEnabled
772
754
  ? createElement(RefreshControl, extendObject({
773
755
  progressBackgroundColor: refresherBackground,