以中文查看
If you are interested in my development process, you may read it, I believe you will gain something
scroll view, Inside scroll, Full page scroll, Nesting ScrollView
npm install react-scroll-paged-view --save
IOS | Android | Web |
---|---|---|
What you can achieve depends on what you can imagine.
Horizontal | Tab | Carousel |
---|---|---|
The ScrollPagedView component encapsulates the inner scrolling component based on the ViewPaged component and uses it through the context.
import ScrollPagedView from 'react-scroll-paged-view'
import InsideScrollView from './InsideScrollView'
...
_onChange = (pageIndex) => {
...
}
render() {
return (
<ScrollPagedView
onChange={this._onChange}
onResponder={this._onResponder}
>
<InsideScrollView />
<InsideScrollView />
<InsideScrollView />
</ScrollPagedView>
)
}
...
...
static contextTypes = {
ScrollView: PropTypes.func,
}
render() {
const ScrollView = this.context.ScrollView
return (
<ScrollView>
...
</ScrollView>
)
}
...
The ViewPaged component is consistent with the ScrollPagedView component and is free to use infinite and autoPlay.
import { ViewPaged } from 'react-scroll-paged-view'
The ScrollPagedView component is based on the ViewPaged component, which can be passed to the props of the ViewPaged as needed. Refer to the props of the ViewPaged component below.
Name | propType | default value | description |
---|---|---|---|
withRef | bool | false | Get ViewPaged instance ref, through the component's getViewPagedInstance method |
Name | propType | default value | description |
---|---|---|---|
nativeProps(native only) | object | {} | RN scrollView Props |
webProps(web only) | object | {} | Web scrollView Props |
RN and web have the same props and the performance is consistent
Name | propType | default value | description |
---|---|---|---|
style | object | {} | ViewPaged style |
initialPage | number | 0 | Initial page index |
vertical | bool | true | Whether to switch the view vertically |
onChange | function | () => {} | Switch paging callbacks, The parameters are currentPage and prevPage |
duration | number | 400 | Animation duration(In milliseconds) |
infinite | bool | false | Whether it is an infinite scroll view |
renderHeader | function/element | undefined | Header Component, The parameters are activeTab, goToPage, width, pos |
renderFooter | function/element | undefined | Footer Component, The parameters are activeTab, goToPage, width, pos |
renderPosition | string | top | Header/Footer direction, There are 4 values, 'top', 'left', 'bottom', 'right' |
autoPlay | bool | false | Whether to auto rotate |
autoPlaySpeed | number | 2000 | Automatic carousel interval (In milliseconds) |
hasAnimation | bool | true | Click to switch whether there is an animation |
locked | bool | false | Whether to allow drag toggle |
preRenderRange | number | 0 | Control the scope of the render component each time it is updated |
isMovingRender | bool | false | Preload the next page when you touch Move |
Name | propType | default value | description |
---|---|---|---|
onStartShouldSetPanResponder | function | () => true | Reference React Native website gesture response system |
onStartShouldSetPanResponderCapture | function | () => false | Reference React Native website gesture response system |
onMoveShouldSetPanResponder | function | () => true | Reference React Native website gesture response system |
onMoveShouldSetPanResponderCapture | function | () => false | Reference React Native website gesture response system |
onPanResponderTerminationRequest | function | () => true | Reference React Native website gesture response system |
onShouldBlockNativeResponder | function | () => true | Reference React Native website gesture response system |
onPanResponderTerminate | function | () => {} | Reference React Native website gesture response system |