Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复swiper-current变化滚动问题 #1684

Merged
merged 3 commits into from
Nov 5, 2024
Merged

修复swiper-current变化滚动问题 #1684

merged 3 commits into from
Nov 5, 2024

Conversation

xiao19880917lu
Copy link
Collaborator

No description provided.

const { nextIndex, nextOffset } = getMultiNextConfig(props.current)
// 1. 安卓需要主动更新下内部状态, 2. IOS不能触发完wcrollTo之后立即updateState, 会造成滑动两次
// 2. setTimeout 是fix 当再渲染过程中触发scrollTo失败的问题
if (Platform.OS === 'ios') {
Copy link
Collaborator

@hiyuki hiyuki Nov 1, 2024

Choose a reason for hiding this comment

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

平台判断统一走__mpx_mode__判断,便于treeShaking

@@ -486,7 +488,6 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
} else if (i === pages.length - 1 && typeof width === 'number') {
nextMargin && (extraStyle.marginRight = nextMargin)
}
// return (<View style={[pageStyle, styles.slide, extraStyle]} key={ 'page' + i}>{children[+page]}</View>)
return (<View style={[pageStyle, styles.slide, extraStyle]} key={ 'page' + i}>
{wrapChildren(
Copy link
Collaborator

Choose a reason for hiding this comment

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

wrapChildren只应该在最顶层使用

@@ -486,7 +488,6 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
} else if (i === pages.length - 1 && typeof width === 'number') {
nextMargin && (extraStyle.marginRight = nextMargin)
}
// return (<View style={[pageStyle, styles.slide, extraStyle]} key={ 'page' + i}>{children[+page]}</View>)
return (<View style={[pageStyle, styles.slide, extraStyle]} key={ 'page' + i}>
{wrapChildren(
{
Copy link
Collaborator

@hiyuki hiyuki Nov 1, 2024

Choose a reason for hiding this comment

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

下面为啥又有normalStyle又有innerstyle?

@@ -461,20 +462,21 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
}

function renderPages () {
const { width, height, total, children } = state
const { width, height } = state
const { children } = props
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里不应该用newChild么?

@@ -254,13 +267,12 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
createAutoPlay()
return
}
if (!Array.isArray(state.children)) {
if (!Array.isArray(props.children)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里newChild才等价于state.children,以及把newChild重命名为children

@@ -394,7 +395,7 @@ const _Carouse = forwardRef<HandlerRef<ScrollView & View, CarouseProps>, Carouse
const scrollElementProps = {
ref: scrollViewRef,
horizontal: props.horizontal,
pagingEnabled: false,
pagingEnabled: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

下面这个scrollView为啥要用animated的?

@hiyuki hiyuki merged commit e66897a into master Nov 5, 2024
6 checks passed
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