 
 
   scrollOnNewVisit: =>
-    return if !@newVisit || @scrolled
+    $(window).off 'scroll', @onWindowScroll
+    newVisit = @newVisit
+    @newVisit = false
 
-    @newVisit = false
+    return if !newVisit || @scrolled
 
     targetId = document.location.hash.substr(1)
 

    $(document).on 'turbolinks:before-cache', @onBeforeCache
    $(document).on 'turbolinks:before-visit', @onBeforeVisit
    $(document).on 'turbolinks:load', @onLoad
    $(window).on 'scroll', @onWindowScroll


  allTargets: (callback) =>


  onLoad: =>
    @scrolled = false
    $(window).off 'scroll', @onWindowScroll
    $(window).on 'scroll', @onWindowScroll

    # Delayed to wait until cacheSnapshot finishes. The delay matches Turbolinks' defer.
    Timeout.set 1, =>
      @deleteLoadedMarker()
