Skip to content

Commit

Permalink
added new property in case of images width are smaller thant window
Browse files Browse the repository at this point in the history
  • Loading branch information
ksairi committed Sep 27, 2019
1 parent 220a186 commit 0d45e9e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ImageSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type PropsType = {
onPress?: Object => void,
customButtons?: (number, (number, animated?: boolean) => void) => Node,
customSlide?: Slide => Node,
imagesWidth: number
};

type StateType = {
Expand Down Expand Up @@ -75,7 +76,9 @@ class ImageSlider extends Component<PropsType, StateType> {
return;
}
const isUpdating = index !== this._getPosition();
const x = Dimensions.get('window').width * index;
const x = (this.props.imagesWidth ?
this.props.imagesWidth : Dimensions.get("window").width)
* index;

this._ref && this._ref.scrollTo({ y: 0, x, animated });

Expand Down

0 comments on commit 0d45e9e

Please sign in to comment.