Fork me on GitHub

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?


@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)))


Thanks. Will try!


@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.