Home » Javascript » Customise animation function for scrolling

Customise animation function for scrolling

Posted by: admin November 1, 2017 Leave a comment

Questions:

In my React Native code, I have a ScrollView component that has a list of images. I am scrolling through the images using the following code:

this.refs[SCROLLVIEW_REF].scrollTo({
  x: this.props.windowWidth * nextIndex * this.getScalingValue(),
  animated: true
});

In the code, this.refs[SCROLLVIEW_REF] references my ScrollView.

The problem with this animation is that it’s too quick and therefore doesn’t look good. I would like the scrolling to be slower. I am thinking to pass a callback that specifies how the animation should be.

I looked on this manual page but the only option that appears here is to pass animated: true. I passed this argument but it didn’t change anything.

So is there any way of customising the animation function?

Can I pass a callback? If not, can I pass some other parameter?

Answers: