Skip to content

修复安卓更新absolute值问题&去掉触发change的条件#2313

Merged
hiyuki merged 11 commits intomasterfrom
fix-swiper-android-absolute
Feb 3, 2026
Merged

修复安卓更新absolute值问题&去掉触发change的条件#2313
hiyuki merged 11 commits intomasterfrom
fix-swiper-android-absolute

Conversation

@xiao19880917lu
Copy link
Collaborator

No description provided.

const circularShared = useSharedValue(circular)
const children = Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])
// 支持swiper-item 同时存在<swiper-item wx:for/>和<swiper-item>并列的情况
const children = (Array.isArray(props.children) ? props.children.filter(child => child) : (props.children ? [props.children] : [])).flat()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接走Children.toArray吧

// 记录元素的偏移量
const offset = useSharedValue(getOffset(propCurrent, initStep))
// 记录起始的offset,用于判断是否超过一半(当前offset + 起始或修正起始offset),基于索引判断是否超过一半不可行(1.滑动过程中索引会变更导致计算反向, 2.边界场景会更新offset也会导致基于索引+offset判断实效)
const preOffset = useSharedValue(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥需要这个,超过一半与否用offset%step与step/2比较就可以了吧

@hiyuki hiyuki merged commit 4a857dd into master Feb 3, 2026
6 checks passed
@hiyuki hiyuki deleted the fix-swiper-android-absolute branch February 3, 2026 12:13
@hiyuki hiyuki restored the fix-swiper-android-absolute branch February 3, 2026 12:14
@hiyuki hiyuki deleted the fix-swiper-android-absolute branch February 3, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants