[SOLVED] scrollTop in FlowRouter triggersEnter?

  • I have a triggersEnter function on one of my routes. It triggers a hopscotch tour.

  • I need to make sure the user is at the top of the page before the tour starts.

  • I have a scrollToTop package that works for safari but for some reason doesn’t work in chrome (haven’t figured out which package is conflicting).

  • As a short-term fix, I’d like to just throw in a scrollTop to the triggersEnter prior to the hopscotch function-- but I can’t seem to get it to work.

  • Do I attach scrollTop to window? body? window.body? Do I need to pass it a 0? Should I be doing this somewhere other than triggersEnter? I’m lost atm.

I’ve tried everything.

Should this be in an onCreated? Or in triggers? Should I use scrollTop or Jquery? Nothing is working.

$(window).scrollTop(0) should do the trick to get you to the top of the page. I would probably throw it into an onRendered call?

1 Like

There is also the okgrow:router-autoscroll package (which will give you some extra functionality).

For some reason this isn’t working in Chrome. I’m guessing I have some sort of conflicting package but it’d take me 2 days to figure out which one it is.



This worked.

One issue was that I was trying to do it with a dynamic template and I needed to do it in the frame around the inner dynamic template area.