     # The result will be wrong when target page is too short anyway.
     @_scrolling = true
 
-    $(window).stop().scrollTo "##{mode}", 500,
+    target = @refs["page-#{mode}"]
+
+    return unless target
+
+    $(window).stop().scrollTo target, 500,
       onAfter: =>
         # Manually set the mode to avoid confusion (wrong highlight).
         # Scrolling will obviously break it but that's unfortunate result


  updateOrder: (element) =>
    oldOrder = @state.profileOrder
    newOrder = $(@refs.pages).sortable('toArray')

    id = element.attr 'id'


      pageTop = page.getBoundingClientRect().top
      continue unless pageTop <= anchorHeight

      @_setMode page.dataset.id
      return

    @_setMode page.dataset.id


  _modeSwitch: (_e, mode) =>
