russellsamora / scrollama

Scrollytelling with IntersectionObserver.

Home Page:https://russellsamora.github.io/scrollama/basic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Skip animation on step jump

puntofisso opened this issue · comments

This is not a bug as such but a reflection that comes from reading #26 - I wonder what's the best way to skip any given number of steps.

Let's say I have 100 steps and have an in-page anchor link. Something like this at the top of the page

<a href="#mystep">Go to step 56</a>

and down below I have a step with that identifier

<div id="mystep" class='step' data-step='56'>...</div>

If I click on the element, the function handleStepEnter() is called 56 times as if I were actually scrolling, thereby building up some (small, but noticeable) delay before the right event is called. What's the best way, if there is one, to "jump" to the 56th element?

You could try to employ the enable/disable functionality. Basically intercept the click, disable scrollama, get the target position/destination, jump scroll to that point, re-enable scrollama.