-
Notifications
You must be signed in to change notification settings - Fork 375
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
修复swiper-current变化滚动问题 #1684
Conversation
const { nextIndex, nextOffset } = getMultiNextConfig(props.current) | ||
// 1. 安卓需要主动更新下内部状态, 2. IOS不能触发完wcrollTo之后立即updateState, 会造成滑动两次 | ||
// 2. setTimeout 是fix 当再渲染过程中触发scrollTo失败的问题 | ||
if (Platform.OS === 'ios') { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( | |||
{ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
下面这个scrollView为啥要用animated的?
No description provided.