 
 export default new Router
   mode: 'history'
+  
   scrollBehavior: (to, from, savedPosition) ->
-    { x: 0, y: 0 }
+    if savedPosition
+      savedPosition
+    else if (to.meta.noScroll and from.meta.noScroll)
+      window.scrollHeight
+    else
+      { x: 0, y: 0 }
+
   routes: [
     {path: '/dashboard', component: DashboardPage},
     {path: '/dashboard/:filter', component: DashboardPage},

Vue.use(Router)

groupPageChildren = [
  {path: 'polls', component: GroupPollsPanel}
  {path: 'members', component: MembersPanel}
  {path: 'membership_requests', component: MembershipRequestsPanel}
  {path: 'members/requests', redirect: 'membership_requests' }
  {path: 'subgroups', component: GroupSubgroupsPanel}
  {path: 'files', component: GroupFilesPanel}
  {path: 'settings', component: GroupSettingsPanel}
  {path: ':stub?', component: GroupDiscussionsPanel}
  {path: 'slack/install', component: InstallSlackPage}
]

threadPageChildren = [

    {path: '/d/new', component: StartDiscussionPage },
    {path: '/d/:key', name: 'discussion', component: ThreadPage, children: threadPageChildren },
    {path: '/g/new', component: StartGroupPage},
    {path: '/g/:key', component: GroupPage, children: groupPageChildren, name: 'groupKey'},
    {path: '/:key', component: GroupPage, children: groupPageChildren},
    {path: '/', redirect: '/dashboard' }
  ]
