I would like to determine if a sammyJS route is being executed for the first time (as in a refresh of the browser) or if the route is being accessed after the initial load of the page.
My use case is, in certain cases when a route is executed, the new content is not visible because the user has scrolled down the page. I’d like to do a $.scrollTo when the user has already loaded the page and THEN clicked on a link that triggers a route, but if the user access the route directly in the address bar, the scrollTo is not executed.
If I get your idea, you simply need a flag that is initially set to false and then switched to true in a route callback. Then you call your scrolling method if the flag is false. The flag scope must be greater than the Sammy app object scope, i.e. you should define the flag before calling Sammy initialization functions. Each time the page is reloaded by the browser the flag will be false again (remember, javascript engine is restarted at each HTML page refresh/reload).
If you need this logic to be applied to any route, you can use one of the
before,afterandaroundevents. Check out the Sammy API docs for details.