@mpxjs/webpack-plugin 2.10.17-unocss.1 → 2.10.18-beta.1

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 +49 -36
  2. package/lib/platform/style/wx/index.js +0 -2
  3. package/lib/platform/template/wx/component-config/camera.js +12 -0
  4. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  5. package/lib/react/processStyles.js +8 -39
  6. package/lib/react/style-helper.js +5 -16
  7. package/lib/resolver/ExtendComponentsPlugin.js +60 -0
  8. package/lib/runtime/components/ali/mpx-section-list.mpx +566 -0
  9. package/lib/runtime/components/ali/mpx-sticky-header.mpx +212 -0
  10. package/lib/runtime/components/ali/mpx-sticky-section.mpx +17 -0
  11. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +0 -1
  12. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +2 -1
  13. package/lib/runtime/components/react/dist/mpx-input.jsx +10 -3
  14. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +13 -2
  15. package/lib/runtime/components/react/dist/mpx-swiper.jsx +60 -40
  16. package/lib/runtime/components/react/dist/utils.jsx +8 -4
  17. package/lib/runtime/components/react/mpx-async-suspense.tsx +2 -1
  18. package/lib/runtime/components/react/mpx-camera.tsx +327 -0
  19. package/lib/runtime/components/react/mpx-input.tsx +11 -2
  20. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +13 -2
  21. package/lib/runtime/components/react/mpx-section-list.tsx +439 -0
  22. package/lib/runtime/components/react/mpx-swiper.tsx +113 -66
  23. package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
  24. package/lib/runtime/components/react/tsconfig.json +1 -1
  25. package/lib/runtime/components/react/utils.tsx +8 -4
  26. package/lib/runtime/components/web/mpx-scroll-view.vue +5 -2
  27. package/lib/runtime/components/web/mpx-section-list.vue +551 -0
  28. package/lib/runtime/components/wx/mpx-section-list-default/list-footer.mpx +26 -0
  29. package/lib/runtime/components/wx/mpx-section-list-default/list-header.mpx +26 -0
  30. package/lib/runtime/components/wx/mpx-section-list-default/list-item.mpx +26 -0
  31. package/lib/runtime/components/wx/mpx-section-list-default/section-header.mpx +26 -0
  32. package/lib/runtime/components/wx/mpx-section-list.mpx +209 -0
  33. package/lib/runtime/components/wx/mpx-sticky-header.mpx +40 -0
  34. package/lib/runtime/components/wx/mpx-sticky-section.mpx +31 -0
  35. package/lib/template-compiler/compiler.js +7 -3
  36. package/lib/utils/const.js +29 -0
  37. package/lib/utils/dom-tag-config.js +1 -1
  38. package/lib/wxss/loader.js +4 -1
  39. package/lib/wxss/utils.js +7 -2
  40. package/package.json +3 -3
@@ -38,6 +38,10 @@ type EventDataType = {
38
38
  // onUpdate时根据上一个判断方向,onFinalize根据transformStart判断
39
39
  transdir: number
40
40
  }
41
+ // 只基于方向 + offset 计算最终的索引
42
+ type EventEndType = {
43
+ transdir: number
44
+ }
41
45
 
42
46
  interface SwiperProps {
43
47
  children?: ReactNode
@@ -73,6 +77,7 @@ interface SwiperProps {
73
77
  'wait-for'?: Array<GestureHandler>
74
78
  'simultaneous-handlers'?: Array<GestureHandler>
75
79
  disableGesture?: boolean
80
+ 'display-multiple-items'?: number
76
81
  bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
77
82
  }
78
83
 
@@ -167,6 +172,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
167
172
  marginBottom: dotSpacing,
168
173
  zIndex: 98
169
174
  }
175
+ const displayMultipleItems = props['display-multiple-items'] || 1
170
176
  const easeingFunc = props['easing-function'] || 'default'
171
177
  const easeDuration = props.duration || 500
172
178
  const horizontal = props.vertical !== undefined ? !props.vertical : true
@@ -200,18 +206,19 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
200
206
  const preMarginShared = useSharedValue(preMargin)
201
207
  const nextMarginShared = useSharedValue(nextMargin)
202
208
  const autoplayShared = useSharedValue(autoplay)
209
+ const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
203
210
  // 默认前后补位的元素个数
204
- const patchElmNum = circular ? (preMargin ? 2 : 1) : 0
211
+ const patchElmNum = (circular && children.length > 1) ? displayMultipleItems + 1 : 0
205
212
  const patchElmNumShared = useSharedValue(patchElmNum)
213
+ const displayMultipleItemsShared = useSharedValue(displayMultipleItems)
206
214
  const circularShared = useSharedValue(circular)
207
- const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
208
215
  // 对有变化的变量,在worklet中只能使用sharedValue变量,useRef不能更新
209
216
  const childrenLength = useSharedValue(children.length)
210
217
  const initWidth = typeof normalStyle?.width === 'number' ? normalStyle.width - preMargin - nextMargin : normalStyle.width
211
218
  const initHeight = typeof normalStyle?.height === 'number' ? normalStyle.height - preMargin - nextMargin : normalStyle.height
212
219
  const dir = horizontal === false ? 'y' : 'x'
213
220
  const pstep = dir === 'x' ? initWidth : initHeight
214
- const initStep: number = isNaN(pstep) ? 0 : pstep
221
+ const initStep: number = isNaN(pstep) ? 0 : pstep / displayMultipleItems
215
222
  // 每个元素的宽度 or 高度,有固定值直接初始化无则0
216
223
  const step = useSharedValue(initStep)
217
224
  // 记录选中元素的索引值
@@ -227,8 +234,12 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
227
234
  const preAbsolutePos = useSharedValue(0)
228
235
  // 记录从onBegin 到 onTouchesUp 时移动的距离
229
236
  const moveTranstion = useSharedValue(0)
237
+ // 记录用户手滑动的方向
238
+ const moveDir = useSharedValue(0)
230
239
  const timerId = useRef(0 as number | ReturnType<typeof setTimeout>)
231
240
  const intervalTimer = props.interval || 500
241
+ // 记录是否首次,首次不能触发bindchange回调
242
+ const isFirstRef = useRef(true)
232
243
 
233
244
  const simultaneousHandlers = flatGesture(originSimultaneousHandlers)
234
245
  const waitForHandlers = flatGesture(waitFor)
@@ -285,7 +296,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
285
296
  const { width, height } = e.nativeEvent.layout
286
297
  const realWidth = dir === 'x' ? width - preMargin - nextMargin : width
287
298
  const realHeight = dir === 'y' ? height - preMargin - nextMargin : height
288
- const iStep = dir === 'x' ? realWidth : realHeight
299
+ const iStep = (dir === 'x' ? realWidth : realHeight) / displayMultipleItems
289
300
  if (iStep !== step.value) {
290
301
  step.value = iStep
291
302
  updateCurrent(propCurrent, iStep)
@@ -344,18 +355,35 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
344
355
  function renderItems () {
345
356
  const intLen = children.length
346
357
  let renderChild = children.slice()
358
+ // if (circular && intLen > 1) {
359
+ // // 最前面加最后一个元素
360
+ // const lastChild = React.cloneElement(children[intLen - 1] as ReactElement, { key: 'clone0' })
361
+ // // 最后面加第一个元素
362
+ // const firstChild = React.cloneElement(children[0] as ReactElement, { key: 'clone1' })
363
+ // if (preMargin) {
364
+ // const lastChild1 = React.cloneElement(children[intLen - 2] as ReactElement, { key: 'clone2' })
365
+ // const firstChild1 = React.cloneElement(children[1] as ReactElement, { key: 'clone3' })
366
+ // renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1])
367
+ // } else {
368
+ // renderChild = [lastChild].concat(renderChild).concat([firstChild])
369
+ // }
370
+ // }
347
371
  if (circular && intLen > 1) {
348
- // 最前面加最后一个元素
349
- const lastChild = React.cloneElement(children[intLen - 1] as ReactElement, { key: 'clone0' })
350
- // 最后面加第一个元素
351
- const firstChild = React.cloneElement(children[0] as ReactElement, { key: 'clone1' })
352
- if (preMargin) {
353
- const lastChild1 = React.cloneElement(children[intLen - 2] as ReactElement, { key: 'clone2' })
354
- const firstChild1 = React.cloneElement(children[1] as ReactElement, { key: 'clone3' })
355
- renderChild = [lastChild1, lastChild].concat(renderChild).concat([firstChild, firstChild1])
356
- } else {
357
- renderChild = [lastChild].concat(renderChild).concat([firstChild])
372
+ // 动态生成前置补位元素
373
+ const frontClones = []
374
+ // 计算补位序列的起始索引。例如 len=3, patch=2 -> start=1 (即从B开始)
375
+ const startIndex = intLen - (patchElmNum % intLen)
376
+ for (let i = 0; i < patchElmNum; i++) {
377
+ const sourceIndex = (startIndex + i) % intLen
378
+ frontClones.push(React.cloneElement(children[sourceIndex], { key: `clone_front_${i}` }))
379
+ }
380
+ // 动态生成后置补位元素
381
+ const backClones = []
382
+ for (let i = 0; i < patchElmNum; i++) {
383
+ const sourceIndex = i % intLen
384
+ backClones.push(React.cloneElement(children[sourceIndex], { key: `clone_back_${i}` }))
358
385
  }
386
+ renderChild = [...frontClones, ...renderChild, ...backClones]
359
387
  }
360
388
  const arrChildren = renderChild.map((child, index) => {
361
389
  const extraStyle = {} as { [key: string]: any }
@@ -390,7 +418,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
390
418
  let nextIndex = currentIndex.value
391
419
  if (!circularShared.value) {
392
420
  // 获取下一个位置的坐标, 循环到最后一个元素,直接停止, 取消定时器
393
- if (currentIndex.value === childrenLength.value - 1) {
421
+ if (currentIndex.value === childrenLength.value - displayMultipleItemsShared.value) {
394
422
  pauseLoop()
395
423
  return
396
424
  }
@@ -456,11 +484,9 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
456
484
  }
457
485
  }, [])
458
486
 
459
- function handleSwiperChange (current: number, pCurrent: number) {
460
- if (pCurrent !== currentIndex.value) {
461
- const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef })
462
- bindchange && bindchange(eventData)
463
- }
487
+ function handleSwiperChange (current: number) {
488
+ const eventData = getCustomEvent('change', {}, { detail: { current, source: 'touch' }, layoutRef: layoutRef })
489
+ bindchange && bindchange(eventData)
464
490
  }
465
491
 
466
492
  const runOnJSCallbackRef = useRef({
@@ -509,9 +535,10 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
509
535
  // 1. 用户在当前页切换选中项,动画;用户携带选中index打开到swiper页直接选中不走动画
510
536
  useAnimatedReaction(() => currentIndex.value, (newIndex: number, preIndex: number) => {
511
537
  // 这里必须传递函数名, 直接写()=> {}形式会报 访问了未sharedValue信息
512
- if (newIndex !== preIndex && bindchange) {
538
+ if (newIndex !== preIndex && bindchange && !isFirstRef.current) {
513
539
  runOnJS(runOnJSCallback)('handleSwiperChange', newIndex, propCurrent)
514
540
  }
541
+ isFirstRef.current = false
515
542
  })
516
543
 
517
544
  useEffect(() => {
@@ -560,16 +587,17 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
560
587
  }
561
588
  }
562
589
  }, [autoplay])
563
-
564
590
  useEffect(() => {
565
- if (circular !== circularShared.value) {
591
+ if (circular !== circularShared.value || patchElmNum !== patchElmNumShared.value || displayMultipleItems !== displayMultipleItemsShared.value) {
566
592
  circularShared.value = circular
567
- patchElmNumShared.value = circular ? (preMargin ? 2 : 1) : 0
593
+ patchElmNumShared.value = patchElmNum
594
+ displayMultipleItemsShared.value = displayMultipleItems
568
595
  offset.value = getOffset(currentIndex.value, step.value)
569
596
  }
570
- }, [circular, preMargin])
597
+ }, [circular, patchElmNum, displayMultipleItems])
571
598
  const { gestureHandler } = useMemo(() => {
572
- function getTargetPosition (eventData: EventDataType) {
599
+ // 基于transdir + 当前offset计算索引
600
+ function getTargetPosition (eventData: EventEndType) {
573
601
  'worklet'
574
602
  // 移动的距离
575
603
  const { transdir } = eventData
@@ -585,7 +613,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
585
613
  const moveToIndex = transdir < 0 ? Math.ceil(computedIndex) : Math.floor(computedIndex)
586
614
  // 实际应该定位的索引值
587
615
  if (!circularShared.value) {
588
- selectedIndex = moveToIndex
616
+ const maxIndex = Math.max(0, childrenLength.value - displayMultipleItemsShared.value)
617
+ selectedIndex = Math.min(Math.max(moveToIndex, 0), maxIndex)
589
618
  moveToTargetPos = selectedIndex * step.value
590
619
  } else {
591
620
  if (moveToIndex >= childrenLength.value + patchElmNumShared.value) {
@@ -618,7 +647,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
618
647
  const gestureMovePos = offset.value + translation
619
648
  if (!circularShared.value) {
620
649
  // 如果只判断区间,中间非滑动状态(handleResistanceMove)向左滑动,突然改为向右滑动,但是还在非滑动态,本应该可滑动判断为了不可滑动
621
- const posEnd = -step.value * (childrenLength.value - 1)
650
+ const posEnd = -step.value * (childrenLength.value - displayMultipleItemsShared.value)
622
651
  if (transdir < 0) {
623
652
  return gestureMovePos > posEnd
624
653
  } else {
@@ -628,7 +657,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
628
657
  return true
629
658
  }
630
659
  }
631
- function handleEnd (eventData: EventDataType) {
660
+ function handleEnd (eventData: EventEndType) {
632
661
  'worklet'
633
662
  const { isCriticalItem, targetOffset, resetOffset, selectedIndex } = getTargetPosition(eventData)
634
663
  if (isCriticalItem) {
@@ -654,7 +683,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
654
683
  })
655
684
  }
656
685
  }
657
- function handleBack (eventData: EventDataType) {
686
+ function handleBack (eventData: EventEndType) {
658
687
  'worklet'
659
688
  const { transdir } = eventData
660
689
  // 向右滑动的back:trans < 0, 向左滑动的back: trans < 0
@@ -675,10 +704,8 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
675
704
  }
676
705
  })
677
706
  }
678
- // 当前的offset和index多对应的offset进行对比,判断是否超过一半
679
- function computeHalf (eventData: EventDataType) {
707
+ function computeHalf () {
680
708
  'worklet'
681
- const { transdir } = eventData
682
709
  const currentOffset = Math.abs(offset.value)
683
710
  let preOffset = (currentIndex.value + patchElmNumShared.value) * step.value
684
711
  if (circularShared.value) {
@@ -687,32 +714,14 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
687
714
  // 正常事件中拿到的translation值(正向滑动<0,倒着滑>0)
688
715
  const diffOffset = preOffset - currentOffset
689
716
  const half = Math.abs(diffOffset) > step.value / 2
690
- const isTriggerUpdateHalf = (transdir < 0 && currentOffset < preOffset) || (transdir > 0 && currentOffset > preOffset)
691
- return {
692
- diffOffset,
693
- half,
694
- isTriggerUpdateHalf
695
- }
696
- }
697
- function handleLongPress (eventData: EventDataType) {
698
- 'worklet'
699
- const { diffOffset, half, isTriggerUpdateHalf } = computeHalf(eventData)
700
- if (+diffOffset === 0) {
701
- runOnJS(runOnJSCallback)('resumeLoop')
702
- } else if (isTriggerUpdateHalf) {
703
- // 如果触发了onUpdate时的索引变更
704
- handleEnd(eventData)
705
- } else if (half) {
706
- handleEnd(eventData)
707
- } else {
708
- handleBack(eventData)
709
- }
717
+ return half
710
718
  }
711
719
  function reachBoundary (eventData: EventDataType) {
712
720
  'worklet'
713
721
  // 1. 基于当前的offset和translation判断是否超过当前边界值
714
722
  const { translation } = eventData
715
- const boundaryStart = -patchElmNumShared.value * step.value
723
+ // 与终点的逻辑对齐,都是超过补位元素对应的起点offset
724
+ const boundaryStart = 0
716
725
  const boundaryEnd = -(childrenLength.value + patchElmNumShared.value) * step.value
717
726
  const moveToOffset = offset.value + translation
718
727
  let isBoundary = false
@@ -729,7 +738,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
729
738
  // 超过边界的距离
730
739
  const exceedLength = Math.abs(boundaryStart) - Math.abs(moveToOffset)
731
740
  // 计算对标正常元素所在的offset
732
- resetOffset = (patchElmNumShared.value + childrenLength.value - 1) * step.value + (step.value - exceedLength)
741
+ resetOffset = (patchElmNumShared.value + childrenLength.value - 1) * step.value - exceedLength
733
742
  }
734
743
  return {
735
744
  isBoundary,
@@ -742,7 +751,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
742
751
  const { translation, transdir } = eventData
743
752
  const moveToOffset = offset.value + translation
744
753
  const maxOverDrag = Math.floor(step.value / 2)
745
- const maxOffset = translation < 0 ? -(childrenLength.value - 1) * step.value : 0
754
+ const maxOffset = translation < 0 ? -(childrenLength.value - displayMultipleItemsShared.value) * step.value : 0
746
755
  let resistance = 0.1
747
756
  let overDrag = 0
748
757
  let finalOffset = 0
@@ -766,6 +775,14 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
766
775
  }
767
776
  return finalOffset
768
777
  }
778
+ // 设置手势移动的方向
779
+ function setMoveDir (curAbsoPos: number) {
780
+ 'worklet'
781
+ const distance = curAbsoPos - preAbsolutePos.value
782
+ if (distance) {
783
+ moveDir.value = curAbsoPos - preAbsolutePos.value
784
+ }
785
+ }
769
786
  const gesturePan = Gesture.Pan()
770
787
  .onBegin((e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
771
788
  'worklet'
@@ -785,9 +802,9 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
785
802
  transdir: moveDistance
786
803
  }
787
804
  // 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
788
- const { half } = computeHalf(eventData)
789
- if (childrenLength.value > 1 && half) {
790
- const { selectedIndex } = getTargetPosition(eventData)
805
+ const offsetHalf = computeHalf()
806
+ if (childrenLength.value > 1 && offsetHalf) {
807
+ const { selectedIndex } = getTargetPosition({ transdir: moveDistance } as EventEndType)
791
808
  currentIndex.value = selectedIndex
792
809
  }
793
810
  // 2. 非循环: 处理用户一直拖拽到临界点的场景,如果放到onFinalize无法阻止offset.value更新为越界的值
@@ -798,6 +815,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
798
815
  const finalOffset = handleResistanceMove(eventData)
799
816
  offset.value = finalOffset
800
817
  }
818
+ setMoveDir(e[strAbso])
801
819
  preAbsolutePos.value = e[strAbso]
802
820
  return
803
821
  }
@@ -805,6 +823,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
805
823
  if (circularShared.value && childrenLength.value === 1) {
806
824
  const finalOffset = handleResistanceMove(eventData)
807
825
  offset.value = finalOffset
826
+ setMoveDir(e[strAbso])
808
827
  preAbsolutePos.value = e[strAbso]
809
828
  return
810
829
  }
@@ -815,6 +834,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
815
834
  } else {
816
835
  offset.value = moveDistance + offset.value
817
836
  }
837
+ setMoveDir(e[strAbso])
818
838
  preAbsolutePos.value = e[strAbso]
819
839
  })
820
840
  .onFinalize((e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => {
@@ -822,10 +842,21 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
822
842
  if (touchfinish.value) return
823
843
  touchfinish.value = true
824
844
  // 触发过onUpdate正常情况下e[strAbso] - preAbsolutePos.value=0; 未触发过onUpdate的情况下e[strAbso] - preAbsolutePos.value 不为0
845
+ // 正常状态下基于onUpdate时的moveDir判断方向、未触发onUpdate的则基于onBegin的moveTranstion判断方向
825
846
  const moveDistance = e[strAbso] - preAbsolutePos.value
847
+ // 默认兜底方向: 以onBegin为起点,因一些原因未触发onUpdate但是触发了位移
848
+ const defaultDir = e[strAbso] - moveTranstion.value
849
+ // 实时方向:方向基于onUpdate时的方向,滑动的速度超过阈值时基于实时的滑动方向计算
850
+ const realtimeData = {
851
+ transdir: moveDir.value || defaultDir
852
+ }
853
+ // 起始方向:基于用户起始手势
854
+ const originData = {
855
+ transdir: defaultDir
856
+ }
826
857
  const eventData = {
827
858
  translation: moveDistance,
828
- transdir: moveDistance !== 0 ? moveDistance : e[strAbso] - moveTranstion.value
859
+ transdir: realtimeData.transdir
829
860
  }
830
861
  // 1. 只有一个元素:循环 和 非循环状态,都走回弹效果
831
862
  if (childrenLength.value === 1) {
@@ -839,19 +870,35 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
839
870
  // 非循环支持最后元素可滑动能力后,向左快速移动未超过最大可移动范围一半,因为offset为正值,向左滑动handleBack,默认向上取整
840
871
  // 但是在offset大于0时,取0。[-100, 0](back取0), [0, 100](back取1), 所以handleLongPress里的处理逻辑需要兼容支持,因此这里直接单独处理,不耦合下方公共的判断逻辑。
841
872
  if (!circularShared.value && !canMove(eventData)) {
842
- if (eventData.transdir < 0) {
843
- handleBack(eventData)
873
+ if (realtimeData.transdir < 0) {
874
+ handleBack(realtimeData)
844
875
  } else {
845
- handleEnd(eventData)
876
+ handleEnd(realtimeData)
846
877
  }
847
878
  return
848
879
  }
849
880
  // 3. 非循环状态可移动态、循环状态, 正常逻辑处理
850
881
  const velocity = e[strVelocity]
851
- if (Math.abs(velocity) < longPressRatio) {
852
- handleLongPress(eventData)
882
+ // 用于判断是否超过一半,基于索引判断是否超过一半不可行(1.滑动过程中索引会变更导致计算反向, 2.边界场景会更新offset也会导致基于索引+offset判断实效)
883
+ const tmp = offset.value % step.value > step.value / 2
884
+ // 小于0手向左滑动
885
+ const offsetHalf = originData.transdir < 0 ? tmp : !tmp
886
+ if (offsetHalf) {
887
+ if (Math.abs(velocity) > longPressRatio) {
888
+ // 超过速度阈值,按照实时方向(快速来回滑动)
889
+ handleEnd(realtimeData)
890
+ } else {
891
+ // 超过速度阈值,按照起始方向(慢速长按)
892
+ handleEnd(originData)
893
+ }
853
894
  } else {
854
- handleEnd(eventData)
895
+ if (Math.abs(velocity) > longPressRatio) {
896
+ // 超过速度阈值,按照实时方向(快速来回滑动)
897
+ handleEnd(realtimeData)
898
+ } else {
899
+ // 超过速度阈值,按照起始方向(慢速长按)
900
+ handleBack(originData)
901
+ }
855
902
  }
856
903
  })
857
904
  .withRef(swiperGestureRef)
@@ -234,7 +234,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
234
234
  }
235
235
  break
236
236
  case 'postMessage':
237
- bindmessage && bindmessage(getCustomEvent('messsage', {}, { // RN组件销毁顺序与小程序不一致,所以改成和支付宝消息一致
237
+ bindmessage && bindmessage(getCustomEvent('message', {}, { // RN组件销毁顺序与小程序不一致,所以改成和支付宝消息一致
238
238
  detail: {
239
239
  data: params[0]?.data
240
240
  }
@@ -3,7 +3,7 @@
3
3
  "include": [
4
4
  "./"
5
5
  ],
6
- "exclude": [],
6
+ "exclude": ["./dist/"],
7
7
  "compilerOptions": {
8
8
  "target": "esnext",
9
9
  "module": "esnext",
@@ -550,7 +550,7 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
550
550
  // transform rpx to px
551
551
  transformBoxShadow(normalStyle)
552
552
  // transform 字符串格式转化数组格式(先转数组再处理css var)
553
- transformTransform(styleObj)
553
+ transformTransform(normalStyle)
554
554
 
555
555
  return {
556
556
  hasVarDec,
@@ -755,10 +755,14 @@ export function getCurrentPage (pageId: number | null | undefined) {
755
755
 
756
756
  export function renderImage (
757
757
  imageProps: ImageProps | FastImageProps,
758
- enableFastImage = false
758
+ enableFastImage = true
759
759
  ) {
760
- // eslint-disable-next-line @typescript-eslint/no-var-requires
761
- const Component: React.ComponentType<ImageProps | FastImageProps> = enableFastImage ? require('@d11/react-native-fast-image') : Image
760
+ let Component: React.ComponentType<ImageProps | FastImageProps> = Image
761
+ if (enableFastImage) {
762
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
763
+ const fastImageModule = require('@d11/react-native-fast-image')
764
+ Component = fastImageModule.default || fastImageModule
765
+ }
762
766
  return createElement(Component, imageProps)
763
767
  }
764
768
 
@@ -380,7 +380,7 @@
380
380
  const top = item.offsetTop
381
381
  const width = item.offsetWidth
382
382
  const height = item.offsetHeight
383
-
383
+
384
384
  minLeft = getMinLength(minLeft, left)
385
385
  minTop = getMinLength(minTop, top)
386
386
  maxRight = getMaxLength(maxRight, left + width)
@@ -414,6 +414,9 @@
414
414
  if (this.bs) this.bs.refresh()
415
415
  }
416
416
  },
417
+ forceUpdateRefreshVersion () {
418
+ this.refreshVersion++
419
+ },
417
420
  compare(num1, num2, scale = 1) {
418
421
  return Math.abs(num1 - num2) < scale
419
422
  },
@@ -588,4 +591,4 @@
588
591
  background: rgba(255, 255, 255, .7)
589
592
  100%
590
593
  background: rgba(255, 255, 255, .3)
591
- </style>
594
+ </style>