@mpxjs/webpack-plugin 2.9.69-beta.1 → 2.9.69-beta.3

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 (40) hide show
  1. package/lib/index.js +1 -17
  2. package/lib/platform/style/wx/index.js +18 -18
  3. package/lib/platform/template/wx/component-config/movable-view.js +1 -8
  4. package/lib/platform/template/wx/component-config/scroll-view.js +1 -1
  5. package/lib/resolver/AddEnvPlugin.js +0 -1
  6. package/lib/resolver/AddModePlugin.js +0 -1
  7. package/lib/runtime/components/react/context.ts +0 -8
  8. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +1 -1
  9. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +42 -51
  10. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +12 -2
  11. package/lib/runtime/components/react/dist/mpx-web-view.jsx +2 -2
  12. package/lib/runtime/components/react/dist/utils.jsx +3 -2
  13. package/lib/runtime/components/react/getInnerListeners.ts +5 -3
  14. package/lib/runtime/components/react/mpx-input.tsx +1 -1
  15. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  16. package/lib/runtime/components/react/mpx-picker-view-column.tsx +145 -177
  17. package/lib/runtime/components/react/mpx-picker-view.tsx +37 -35
  18. package/lib/runtime/components/react/mpx-rich-text/index.tsx +18 -12
  19. package/lib/runtime/components/react/mpx-scroll-view.tsx +10 -19
  20. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +527 -0
  21. package/lib/runtime/components/react/mpx-swiper/index.tsx +80 -0
  22. package/lib/runtime/components/react/mpx-swiper/type.ts +87 -0
  23. package/lib/runtime/components/react/mpx-swiper-item.tsx +10 -38
  24. package/lib/runtime/components/react/mpx-view.tsx +51 -11
  25. package/lib/runtime/components/react/mpx-web-view.tsx +11 -55
  26. package/lib/runtime/components/react/pickerFaces.ts +7 -15
  27. package/lib/runtime/components/react/{pickerViewOverlay.tsx → pickerOverlay.tsx} +3 -5
  28. package/lib/runtime/components/react/types/global.d.ts +1 -3
  29. package/lib/runtime/components/react/useAnimationHooks.ts +1 -1
  30. package/lib/runtime/components/react/utils.tsx +3 -72
  31. package/lib/style-compiler/index.js +4 -3
  32. package/lib/template-compiler/compiler.js +14 -9
  33. package/lib/utils/hump-dash.js +1 -1
  34. package/lib/utils/pre-process-json.js +9 -5
  35. package/package.json +1 -1
  36. package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +0 -88
  37. package/lib/runtime/components/react/mpx-swiper.tsx +0 -690
  38. package/lib/runtime/components/react/pickerVIewContext.ts +0 -18
  39. package/lib/runtime/components/react/pickerViewMask.tsx +0 -30
  40. package/lib/style-compiler/strip-conditional-loader.js +0 -118
package/lib/index.js CHANGED
@@ -54,13 +54,11 @@ const wxssLoaderPath = normalize.lib('wxss/index')
54
54
  const wxmlLoaderPath = normalize.lib('wxml/loader')
55
55
  const wxsLoaderPath = normalize.lib('wxs/loader')
56
56
  const styleCompilerPath = normalize.lib('style-compiler/index')
57
- const styleStripConditaionalPath = normalize.lib('style-compiler/strip-conditional-loader')
58
57
  const templateCompilerPath = normalize.lib('template-compiler/index')
59
58
  const jsonCompilerPath = normalize.lib('json-compiler/index')
60
59
  const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
61
60
  const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
62
61
  const extractorPath = normalize.lib('extractor')
63
- const selectorPath = normalize.lib('selector')
64
62
  const async = require('async')
65
63
  const { parseQuery } = require('loader-utils')
66
64
  const stringifyLoadersAndResource = require('./utils/stringify-loaders-resource')
@@ -1777,7 +1775,7 @@ try {
1777
1775
  })
1778
1776
 
1779
1777
  const typeLoaderProcessInfo = {
1780
- styles: ['node_modules/css-loader', wxssLoaderPath, styleCompilerPath, styleStripConditaionalPath],
1778
+ styles: ['node_modules/css-loader', wxssLoaderPath, styleCompilerPath],
1781
1779
  template: ['node_modules/html-loader', wxmlLoaderPath, templateCompilerPath]
1782
1780
  }
1783
1781
 
@@ -1835,20 +1833,6 @@ try {
1835
1833
  loader: extractorPath
1836
1834
  })
1837
1835
  }
1838
- if (type === 'styles') {
1839
- // 判断最后一个loader是否是 selectorPath, 如果是,则在sectorPath之前插入strip-conditional
1840
- const lastLoader = loaders[loaders.length - 1]
1841
- if (lastLoader.loader.includes(selectorPath)) {
1842
- loaders.splice(loaders.length - 1, 0, {
1843
- loader: styleStripConditaionalPath
1844
- })
1845
- } else {
1846
- // 在最后一个插入strip-conditional
1847
- loaders.push({
1848
- loader: styleStripConditaionalPath
1849
- })
1850
- }
1851
- }
1852
1836
  createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
1853
1837
  }
1854
1838
  // mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
@@ -374,11 +374,11 @@ module.exports = function getSpec ({ warn, error }) {
374
374
  // transform 转换
375
375
  const formatTransform = ({ prop, value, selector }, { mode }) => {
376
376
  // css var & 数组直接返回
377
- if (Array.isArray(value) || cssVariableExp.test(value)) return { prop, value }
377
+ if (Array.isArray(value) || calcExp.test(value)) return { prop, value }
378
378
  const values = parseValues(value)
379
379
  const transform = []
380
380
  values.forEach(item => {
381
- const match = item.match(/([/\w]+)\((.+)\)/)
381
+ const match = item.match(/([/\w]+)\(([^)]+)\)/)
382
382
  if (match && match.length >= 3) {
383
383
  let key = match[1]
384
384
  const val = match[2]
@@ -407,23 +407,23 @@ module.exports = function getSpec ({ warn, error }) {
407
407
  case 'rotate3d': // x y z angle
408
408
  case 'translate3d': // x y 支持 z不支持
409
409
  case 'scale3d': // x y 支持 z不支持
410
- {
411
- // 2 个以上的值处理
412
- key = key.replace('3d', '')
413
- const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
414
- // scale(.5) === scaleX(.5) scaleY(.5)
415
- if (vals.length === 1 && key === 'scale') {
416
- vals.push(vals[0])
417
- }
418
- const xyz = ['X', 'Y', 'Z']
419
- transform.push(...vals.map((v, index) => {
420
- if (key !== 'rotate' && index > 1) {
421
- unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
410
+ {
411
+ // 2 个以上的值处理
412
+ key = key.replace('3d', '')
413
+ const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
414
+ // scale(.5) === scaleX(.5) scaleY(.5)
415
+ if (vals.length === 1 && key === 'scale') {
416
+ vals.push(vals[0])
422
417
  }
423
- return { [`${key}${xyz[index] || ''}`]: v.trim() }
424
- }))
425
- break
426
- }
418
+ const xyz = ['X', 'Y', 'Z']
419
+ transform.push(...vals.map((v, index) => {
420
+ if (key !== 'rotate' && index > 1) {
421
+ unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
422
+ }
423
+ return { [`${key}${xyz[index] || ''}`]: v.trim() }
424
+ }))
425
+ break
426
+ }
427
427
  case 'translateZ':
428
428
  case 'scaleZ':
429
429
  default:
@@ -2,8 +2,6 @@ const TAG_NAME = 'movable-view'
2
2
 
3
3
  module.exports = function ({ print }) {
4
4
  const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
5
- const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
6
- const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
7
5
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
8
6
  const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
9
7
  const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
@@ -29,7 +27,7 @@ module.exports = function ({ print }) {
29
27
  android: androidPropLog
30
28
  },
31
29
  {
32
- test: /^(damping|friction|scale|scale-min|scale-max|scale-value)$/,
30
+ test: /^(inertia|damping|animation)$/,
33
31
  ios: iosPropLog,
34
32
  android: androidPropLog
35
33
  }
@@ -38,11 +36,6 @@ module.exports = function ({ print }) {
38
36
  {
39
37
  test: /^(htouchmove|vtouchmove)$/,
40
38
  ali: aliEventLog
41
- },
42
- {
43
- test: /^(bindscale)$/,
44
- ios: iosEventLog,
45
- android: androidEventLog
46
39
  }
47
40
  ]
48
41
  }
@@ -53,7 +53,7 @@ module.exports = function ({ print }) {
53
53
  qa: qaPropLog
54
54
  },
55
55
  {
56
- test: /^(refresher-threshold|enable-passive|scroll-anchoring|using-sticky|fast-deceleration|enable-flex)$/,
56
+ test: /^(scroll-into-view|refresher-threshold|enable-passive|scroll-anchoring|using-sticky|fast-deceleration|enable-flex)$/,
57
57
  android: androidPropLog,
58
58
  ios: iosPropLog
59
59
  },
@@ -34,7 +34,6 @@ module.exports = class AddEnvPlugin {
34
34
  if (!extname || !matchCondition(resourcePath, this.fileConditionRules)) return callback()
35
35
  const queryObj = parseQuery(request.query || '?')
36
36
  queryObj.infix = `${queryObj.infix || ''}.${env}`
37
- // css | stylus | less | sass 中 import file 过滤query,避免在对应的 loader 中无法读取到文件
38
37
  obj.query = stringifyQuery(queryObj)
39
38
  obj.path = addInfix(resourcePath, env, extname)
40
39
  obj.relativePath = request.relativePath && addInfix(request.relativePath, env, extname)
@@ -43,7 +43,6 @@ module.exports = class AddModePlugin {
43
43
  resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + mode, resolveContext, (err, result) => {
44
44
  if (defaultMode && !result) {
45
45
  queryObj.infix = `${queryInfix || ''}.${defaultMode}`
46
- // css | stylus | less | sass 中 import file 过滤query,避免在对应的 loader 中无法读取到文件
47
46
  obj.query = stringifyQuery(queryObj)
48
47
  obj.path = addInfix(resourcePath, defaultMode, extname)
49
48
  resolver.doResolve(target, Object.assign({}, request, obj), 'add mode: ' + defaultMode, resolveContext, (err, result) => {
@@ -33,10 +33,6 @@ export interface IntersectionObserver {
33
33
  }
34
34
  }
35
35
 
36
- export interface ScrollViewContextValue {
37
- gestureRef: React.RefObject<any> | null
38
- }
39
-
40
36
  export const MovableAreaContext = createContext({ width: 0, height: 0 })
41
37
 
42
38
  export const FormContext = createContext<FormContextValue | null>(null)
@@ -55,8 +51,4 @@ export const IntersectionObserverContext = createContext<IntersectionObserver |
55
51
 
56
52
  export const RouteContext = createContext<number | null>(null)
57
53
 
58
- export const SwiperContext = createContext({})
59
-
60
54
  export const KeyboardAvoidContext = createContext<KeyboardAvoidContextValue | null>(null)
61
-
62
- export const ScrollViewContext = createContext<ScrollViewContextValue>({ gestureRef: null })
@@ -3,7 +3,7 @@ import Reanimated, { Extrapolation, interpolate, useAnimatedStyle, useSharedValu
3
3
  import { wrapChildren, extendObject } from './utils';
4
4
  import { createFaces } from './pickerFaces';
5
5
  import { usePickerViewColumnAnimationContext } from './pickerVIewContext';
6
- const _PickerViewColumnItem = ({ item, index, itemHeight, itemWidth, textStyleFromParent, textStyle, hasVarDec, varContext, textProps, visibleCount, onItemLayout }) => {
6
+ const _PickerViewColumnItem = ({ item, index, itemHeight, itemWidth = '100%', textStyleFromParent, textStyle, hasVarDec, varContext, textProps, visibleCount, onItemLayout }) => {
7
7
  const offsetYShared = usePickerViewColumnAnimationContext();
8
8
  const facesShared = useSharedValue(createFaces(itemHeight, visibleCount));
9
9
  useEffect(() => {
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef, useRef, useState, useMemo, useEffect, useCallback } from 'react';
2
2
  import { SafeAreaView, StyleSheet } from 'react-native';
3
3
  import Reanimated, { useAnimatedRef, useScrollViewOffset } from 'react-native-reanimated';
4
- import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid } from './utils';
4
+ import { useTransformStyle, splitStyle, splitProps, useLayout, usePrevious, isAndroid, useDebounceCallback, useStableCallback, isIOS } from './utils';
5
5
  import useNodesRef from './useNodesRef';
6
6
  import PickerOverlay from './pickerViewOverlay';
7
7
  import PickerMask from './pickerViewMask';
@@ -20,11 +20,8 @@ const _PickerViewColumn = forwardRef((props, ref) => {
20
20
  style: normalStyle
21
21
  });
22
22
  const { height: pickerH, itemHeight } = wrapperStyle;
23
- const [scrollViewWidth, setScrollViewWidth] = useState('100%');
24
- const [itemRawW, setItemRawW] = useState('100%');
25
23
  const [itemRawH, setItemRawH] = useState(itemHeight);
26
24
  const maxIndex = useMemo(() => columnData.length - 1, [columnData]);
27
- const maxScrollViewWidth = useRef(-1);
28
25
  const prevScrollingInfo = useRef({ index: initialIndex, y: 0 });
29
26
  const touching = useRef(false);
30
27
  const scrolling = useRef(false);
@@ -39,10 +36,6 @@ const _PickerViewColumn = forwardRef((props, ref) => {
39
36
  nodeRef: scrollViewRef
40
37
  });
41
38
  // console.log('[mpx-picker-view-column], render ---> columnIndex=', columnIndex, 'initialIndex=', initialIndex, 'columnData=', columnData.length, 'pickerH=', pickerH, 'itemRawH=', itemRawH, 'itemHeight=', itemHeight)
42
- // const initialOffset = useMemo(() => ({
43
- // x: 0,
44
- // y: itemRawH * initialIndex
45
- // }), [itemRawH])
46
39
  const paddingHeight = useMemo(() => Math.round((pickerH - itemHeight) / 2), [pickerH, itemHeight]);
47
40
  const snapToOffsets = useMemo(() => columnData.map((_, i) => i * itemRawH), [columnData, itemRawH]);
48
41
  const contentContainerStyle = useMemo(() => {
@@ -52,8 +45,27 @@ const _PickerViewColumn = forwardRef((props, ref) => {
52
45
  const calc = Math.round(y / itemRawH);
53
46
  return Math.max(0, Math.min(calc, maxIndex));
54
47
  }, [itemRawH, maxIndex]);
48
+ const getYofIndex = useCallback((index) => {
49
+ return index * itemRawH;
50
+ }, [itemRawH]);
51
+ const stableResetScrollPosition = useStableCallback((y) => {
52
+ console.log('[mpx-picker-view-column], reset --->', 'columnIndex=', columnIndex, 'y=', y, touching.current, scrolling.current);
53
+ if (touching.current || scrolling.current) {
54
+ return;
55
+ }
56
+ // needReset.current = true
57
+ if (y % itemRawH !== 0) {
58
+ scrolling.current = true;
59
+ const targetIndex = getIndex(y);
60
+ const targetY = getYofIndex(targetIndex);
61
+ scrollViewRef.current?.scrollTo({ x: 0, y: targetY, animated: false });
62
+ }
63
+ else {
64
+ onMomentumScrollEnd({ nativeEvent: { contentOffset: { y } } });
65
+ }
66
+ });
67
+ const debounceResetScrollPosition = useDebounceCallback(stableResetScrollPosition, 10);
55
68
  useEffect(() => {
56
- // console.log('[mpx-picker-view-column], useEffect000 --->', 'columnIndex=', columnIndex, 'initialIndex=', initialIndex, 'prevIndex=', prevIndex, 'activeIndex=', activeIndex.current, 'maxIndex=', maxIndex, 'prevMaxIndex=', prevMaxIndex)
57
69
  if (!scrollViewRef.current ||
58
70
  !itemRawH ||
59
71
  touching.current ||
@@ -64,84 +76,64 @@ const _PickerViewColumn = forwardRef((props, ref) => {
64
76
  maxIndex !== prevMaxIndex) {
65
77
  return;
66
78
  }
67
- // console.log('[mpx-picker-view-column], useEffect ---> columnIndex=', columnIndex, 'initialIndex=', initialIndex, 'y=', itemRawH * initialIndex, `${scrollViewRef.current?.scrollTo}`)
68
79
  setTimeout(() => {
69
80
  scrollViewRef.current?.scrollTo({
70
81
  x: 0,
71
- y: itemRawH * initialIndex,
82
+ y: getYofIndex(initialIndex),
72
83
  animated: false
73
84
  });
74
85
  }, isAndroid ? 200 : 0);
75
86
  activeIndex.current = initialIndex;
76
87
  }, [itemRawH, initialIndex]);
77
88
  const onContentSizeChange = (_w, h) => {
78
- const y = itemRawH * initialIndex;
79
- // console.log('[mpx-picker-view-column], onContentSizeChange --->', 'columnIndex=', columnIndex, '_w=', _w, 'h=', h, 'y=', y, 'itemRawH=', itemRawH)
89
+ const y = getYofIndex(initialIndex);
80
90
  if (y <= h) {
81
91
  setTimeout(() => {
82
92
  scrollViewRef.current?.scrollTo({ x: 0, y, animated: false });
83
93
  }, 0);
84
94
  }
85
95
  };
86
- const onScrollViewLayout = (e) => {
87
- if (isAndroid) {
88
- return;
89
- }
90
- // RN iOS bug: https://github.com/facebook/react-native/issues/36135
91
- const { width } = e.nativeEvent.layout;
92
- const widthInt = Math.ceil(width);
93
- // console.log('[mpx-picker-view-column], onScrollViewLayout --->', 'columnIndex=', columnIndex, 'width=', width, 'widthInt=', widthInt, 'scrollViewWidth=', scrollViewWidth)
94
- if (widthInt !== scrollViewWidth) {
95
- const maxW = maxScrollViewWidth.current;
96
- if (maxW !== -1 && widthInt > maxW) {
97
- return;
98
- }
99
- if (maxW === -1) {
100
- maxScrollViewWidth.current = Math.ceil(widthInt * 1.5);
101
- }
102
- setScrollViewWidth(widthInt);
103
- }
104
- if (itemRawW === '100%') {
105
- setItemRawW(widthInt);
106
- }
107
- };
108
96
  const onItemLayout = (e) => {
109
97
  const { height: rawH } = e.nativeEvent.layout;
110
- // console.log('[mpx-picker-view-column], onItemLayout --->', 'columnIndex=', columnIndex, 'width=', width)
111
98
  if (rawH && itemRawH !== rawH) {
112
99
  setItemRawH(rawH);
113
100
  }
114
101
  };
115
- const onTouchStart = () => {
102
+ const onScrollBeginDrag = () => {
103
+ isIOS && debounceResetScrollPosition.clear();
116
104
  touching.current = true;
117
105
  prevScrollingInfo.current = {
118
106
  index: activeIndex.current,
119
- y: activeIndex.current * itemRawH
107
+ y: getYofIndex(activeIndex.current)
120
108
  };
121
109
  };
122
- const onTouchEnd = () => {
123
- touching.current = false;
124
- };
125
- const onTouchCancel = () => {
110
+ const onScrollEndDrag = (e) => {
126
111
  touching.current = false;
112
+ const { y } = e.nativeEvent.contentOffset;
113
+ if (isIOS) {
114
+ if (y > 0 && y < snapToOffsets[maxIndex]) {
115
+ debounceResetScrollPosition(y);
116
+ }
117
+ }
127
118
  };
128
119
  const onMomentumScrollBegin = () => {
120
+ isIOS && debounceResetScrollPosition.clear();
129
121
  scrolling.current = true;
130
122
  };
131
123
  const onMomentumScrollEnd = (e) => {
132
124
  scrolling.current = false;
133
- if (!itemRawH) {
134
- return;
135
- }
136
125
  const { y: scrollY } = e.nativeEvent.contentOffset;
137
- let calcIndex = Math.round(scrollY / itemRawH);
126
+ if (isIOS && scrollY % itemRawH !== 0) {
127
+ return debounceResetScrollPosition(scrollY);
128
+ }
129
+ const calcIndex = getIndex(scrollY);
138
130
  activeIndex.current = calcIndex;
139
131
  if (calcIndex !== initialIndex) {
140
- calcIndex = Math.max(0, Math.min(calcIndex, maxIndex)) || 0;
141
132
  onSelectChange(calcIndex);
142
133
  }
143
134
  };
144
135
  const onScroll = (e) => {
136
+ const { y } = e.nativeEvent.contentOffset;
145
137
  if (isAndroid) {
146
138
  return;
147
139
  }
@@ -150,7 +142,6 @@ const _PickerViewColumn = forwardRef((props, ref) => {
150
142
  if (typeof pickerVibrate !== 'function') {
151
143
  return;
152
144
  }
153
- const { y } = e.nativeEvent.contentOffset;
154
145
  const { index: prevIndex, y: _y } = prevScrollingInfo.current;
155
146
  if (touching.current || scrolling.current) {
156
147
  if (Math.abs(y - _y) >= itemRawH) {
@@ -158,7 +149,7 @@ const _PickerViewColumn = forwardRef((props, ref) => {
158
149
  if (currentId !== prevIndex) {
159
150
  prevScrollingInfo.current = {
160
151
  index: currentId,
161
- y: currentId * itemRawH
152
+ y: getYofIndex(currentId)
162
153
  };
163
154
  // vibrateShort({ type: 'selection' })
164
155
  pickerVibrate();
@@ -167,11 +158,11 @@ const _PickerViewColumn = forwardRef((props, ref) => {
167
158
  }
168
159
  };
169
160
  const renderInnerchild = () => columnData.map((item, index) => {
170
- return (<MpxPickerVIewColumnItem key={index} item={item} index={index} itemHeight={itemHeight} itemWidth={itemRawW} textStyleFromParent={textStyleFromParent} textStyle={textStyle} hasVarDec={hasVarDec} varContext={varContextRef.current} textProps={textProps} visibleCount={visibleCount} onItemLayout={onItemLayout}/>);
161
+ return (<MpxPickerVIewColumnItem key={index} item={item} index={index} itemHeight={itemHeight} textStyleFromParent={textStyleFromParent} textStyle={textStyle} hasVarDec={hasVarDec} varContext={varContextRef.current} textProps={textProps} visibleCount={visibleCount} onItemLayout={onItemLayout}/>);
171
162
  });
172
163
  const renderScollView = () => {
173
164
  return (<PickerViewColumnAnimationContext.Provider value={offsetYShared}>
174
- <Reanimated.ScrollView ref={scrollViewRef} bounces={true} horizontal={false} nestedScrollEnabled={true} removeClippedSubviews={false} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} scrollEventThrottle={16} {...layoutProps} style={[{ width: scrollViewWidth }]} decelerationRate="fast" snapToOffsets={snapToOffsets} onScroll={onScroll} onLayout={onScrollViewLayout} onTouchStart={onTouchStart} onTouchEnd={onTouchEnd} onTouchCancel={onTouchCancel} onMomentumScrollBegin={onMomentumScrollBegin} onMomentumScrollEnd={onMomentumScrollEnd} onContentSizeChange={onContentSizeChange} contentContainerStyle={contentContainerStyle}>
165
+ <Reanimated.ScrollView ref={scrollViewRef} bounces={true} horizontal={false} nestedScrollEnabled={true} removeClippedSubviews={false} showsVerticalScrollIndicator={false} showsHorizontalScrollIndicator={false} scrollEventThrottle={16} {...layoutProps} style={[{ width: '100%' }]} decelerationRate="fast" snapToOffsets={snapToOffsets} onScroll={onScroll} onScrollBeginDrag={onScrollBeginDrag} onScrollEndDrag={onScrollEndDrag} onMomentumScrollBegin={onMomentumScrollBegin} onMomentumScrollEnd={onMomentumScrollEnd} onContentSizeChange={onContentSizeChange} contentContainerStyle={contentContainerStyle}>
175
166
  {renderInnerchild()}
176
167
  </Reanimated.ScrollView>
177
168
  </PickerViewColumnAnimationContext.Provider>);
@@ -32,7 +32,7 @@
32
32
  * ✔ bindscroll
33
33
  */
34
34
  import { ScrollView } from 'react-native-gesture-handler';
35
- import { RefreshControl } from 'react-native';
35
+ import { RefreshControl, Platform } from 'react-native';
36
36
  import { useRef, useState, useEffect, forwardRef, useContext, createElement, useMemo } from 'react';
37
37
  import { useAnimatedRef } from 'react-native-reanimated';
38
38
  import { warn } from '@mpxjs/utils';
@@ -184,6 +184,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
184
184
  visibleLength
185
185
  });
186
186
  }
187
+ const observerTimers = {};
187
188
  function onScroll(e) {
188
189
  const { bindscroll } = props;
189
190
  const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
@@ -203,7 +204,16 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
203
204
  updateScrollOptions(e, { scrollLeft, scrollTop });
204
205
  if (enableTriggerIntersectionObserver && intersectionObservers) {
205
206
  for (const key in intersectionObservers) {
206
- intersectionObservers[key].throttleMeasure();
207
+ if (Platform.OS === 'android') {
208
+ intersectionObservers[key].throttleMeasure();
209
+ }
210
+ else {
211
+ // TODO: 由于iOS在onScroll滚动的过程中view的计算measureInWindow计算的值不发生变化,所以暂时在ios上加一个延时计算
212
+ observerTimers[key] && clearTimeout(observerTimers[key]);
213
+ observerTimers[key] = setTimeout(() => {
214
+ intersectionObservers[key].throttleMeasure();
215
+ }, 300);
216
+ }
207
217
  }
208
218
  }
209
219
  }
@@ -62,7 +62,7 @@ const _WebView = forwardRef((props, ref) => {
62
62
  src: res.nativeEvent?.url
63
63
  }
64
64
  };
65
- bindload(result);
65
+ bindload?.(result);
66
66
  };
67
67
  const _error = function (res) {
68
68
  const result = {
@@ -72,7 +72,7 @@ const _WebView = forwardRef((props, ref) => {
72
72
  src: ''
73
73
  }
74
74
  };
75
- binderror(result);
75
+ binderror?.(result);
76
76
  };
77
77
  const injectedJavaScript = `
78
78
  if (window.ReactNativeWebView && window.ReactNativeWebView.postMessage) {
@@ -451,13 +451,14 @@ export function wrapChildren(props = {}, { hasVarDec, varContext, textStyle, tex
451
451
  export const debounce = (func, delay) => {
452
452
  let timer;
453
453
  const wrapper = (...args) => {
454
- clearTimeout(timer);
454
+ timer && clearTimeout(timer);
455
455
  timer = setTimeout(() => {
456
456
  func(...args);
457
457
  }, delay);
458
458
  };
459
459
  wrapper.clear = () => {
460
- clearTimeout(timer);
460
+ timer && clearTimeout(timer);
461
+ timer = null;
461
462
  };
462
463
  return wrapper;
463
464
  };
@@ -289,6 +289,7 @@ const useInnerProps = (
289
289
  const eventConfig: { [key: string]: string[] } = {}
290
290
  const config = rawConfig || {
291
291
  layoutRef: { current: {} },
292
+ disableTouch: false,
292
293
  disableTap: false
293
294
  }
294
295
  const removeProps = [
@@ -316,10 +317,11 @@ const useInnerProps = (
316
317
  }
317
318
  }
318
319
 
320
+ if (!rawEventKeys.length || config.disableTouch) {
321
+ return omit(propsRef.current, removeProps)
322
+ }
323
+
319
324
  const events = useMemo(() => {
320
- if (!rawEventKeys.length) {
321
- return {}
322
- }
323
325
  const transformedEventKeys = rawEventKeys.reduce((acc: string[], key) => {
324
326
  if (propsRef.current[key]) {
325
327
  return acc.concat(eventConfig[key])
@@ -149,7 +149,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
149
149
  'parent-font-size': parentFontSize,
150
150
  'parent-width': parentWidth,
151
151
  'parent-height': parentHeight,
152
- 'adjust-position': adjustPosition = false,
152
+ 'adjust-position': adjustPosition = true,
153
153
  bindinput,
154
154
  bindfocus,
155
155
  bindblur,
@@ -11,7 +11,7 @@
11
11
  * ✘ scale-min
12
12
  * ✘ scale-max
13
13
  * ✘ scale-value
14
- * animation
14
+ * animation
15
15
  * ✔ bindchange
16
16
  * ✘ bindscale
17
17
  * ✔ htouchmove