Skip to content

Commit

Permalink
feat(vertical): partical support vertical scrolling (leecade#1017)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayZoneYour authored Jul 16, 2019
1 parent 2cda5bd commit f00abfb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"react-native",
"ios"
],
"version": "1.6.0-nightly.2",
"version": "1.6.0-nightly.4",
"description": "Swiper component for React Native.",
"main": "index.js",
"scripts": {
Expand Down
36 changes: 27 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,20 +435,38 @@ export default class extends Component {
* @param {string} dir 'x' || 'y'
*/
updateIndex = (offset, dir, cb) => {
const state = this.state
// Android ScrollView will not scrollTo certain offset when props change
const callback = () => {
const callback = async () => {
cb()
if (Platform.OS === 'android') {
this.state.index === 0 &&
this.scrollView.scrollTo({ x: state.width, y: 0, animated: false })
this.state.index === this.state.total - 1 &&
this.scrollView.scrollTo({
x: state.width * this.state.total,
animated: false
})
if (this.state.index === 0) {
this.props.horizontal
? this.scrollView.scrollTo({
x: state.width,
y: 0,
animated: false
})
: this.scrollView.scrollTo({
x: 0,
y: state.height,
animated: false
})
} else if (this.state.index === this.state.total - 1) {
this.props.horizontal
? this.scrollView.scrollTo({
x: state.width * this.state.total,
y: 0,
animated: false
})
: this.scrollView.scrollTo({
x: 0,
y: state.height * this.state.total,
animated: false
})
}
}
}
const state = this.state
let index = state.index
if (!this.internals.offset)
// Android not setting this onLayout first? https://github.com/leecade/react-native-swiper/issues/582
Expand Down

0 comments on commit f00abfb

Please sign in to comment.