question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make sure that `onSnapToItem` is triggered AFTER scroll animation's completion

See original GitHub issue

Currently, React Native doesn’t provide a callback for the scrollTo() method, which is a bummer.

The ScrollView component has a prop onScrollAnimationEnd, but unfortunately this works on iOS only (even though it is referenced in the Java file). Moreover, a bug currently prevents the callback from being fired with horizontal scrollers.

Another lead would be to link the duration of the scroll animation to a timer before firing the callback. Unfortunately, scrollTo() doesn’t accept a custom duration.

An idea might be to activate momentum events on Android and see if onMomentumScrollEnd can provide a good enough feedback without impairing performance too much. But this event might not be fired when snapping programatically… Moreover, it is automatically enabled if a momentum callback has been set.

ScrollResponder is another lead worth pursuing…

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
joseygordevcommented, Jun 7, 2017

@bd-arc thank you very much for you attention, component very nice.

1reaction
bd-arccommented, Jun 7, 2017

@piuccio @joseygordev Version 2.2.1 should resolve your issue with the faulty index.

I’ve completely refactored the way callbacks are handled when momentum is disabled. Let’s face it: this is hacky since ScrollView neither provides callbacks to the scrollTo method nor gives access to a onScrollEnd event.

Make sure to play with the new props scrollEndDragThrottleValue and snapCallbackDebounceValue. Let me know how this works for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make sure that `onSnapToItem` is triggered AFTER scroll ...
I just had an idea worth trying, which is to rely on slide animation's completion and to combine it with a time threshold...
Read more >
How to trigger a CSS animation on scroll
This is a step-by-step tutorial for how to create a CSS animation and trigger it on scroll using the Intersection Observer API.
Read more >
How to Make a Scroll-Triggered Animation With Basic JavaScript
The trick is to start the animation when the user scrolls down to that element — scroll-triggered animation, if you will. HTML; CSS;...
Read more >
Having trouble getting the scroll animation to not trigger the ...
It uses bootstrap scrollspy so just ignore that. But notice that it stops any scroll animation that could be running and then also...
Read more >
Trigger Animations on Scroll using HTML, CSS & JavaScript
Learn how to animate your website on scroll using html, css and javascript. We look into javascripts Intersection Observer API to detect ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found