Fork me on GitHub
#reagent
<
2016-03-23
>
pez12:03:27

I’m trying to make scrolling within a page (e.g. when the user clicks a link that takes them to an anchor elsewhere on the page) smooth. Since I use reanimated already my first try was to use anim/interpolate-to, but then I need to do the scrolling from within a rendered component (at least I think so, reagent noob here) and I suppose there must be much better ways to do it. Any ideas?

martinklepsch17:03:48

@pez I usually rely on closurelib for this kind of stuff:

(defn scroll! [el start end time]
  (.play (goog.fx.dom.Scroll. el (clj->js start) (clj->js end) time)))

pez17:03:02

Thanks. Will try!

pez21:03:20

@martinklepsch: Yes, that works. Much better than my first attempt which triggered component updates at each step in the easing. It glitched at times too, which the closurelib way doesn’t.