From 553b49ecd71648ee8aa2243dfeb0060fe68c55b0 Mon Sep 17 00:00:00 2001 From: Marcos Moura Date: Mon, 21 Nov 2016 04:09:42 -0200 Subject: [PATCH] Improve docs transitions --- docs/src/index.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/src/index.js b/docs/src/index.js index 88fb03f..06550a9 100644 --- a/docs/src/index.js +++ b/docs/src/index.js @@ -37,18 +37,18 @@ let router = new VueRouter({ }); let Docs = Vue.component('app', App); -let handleSectionTheme = (route) => { - if (route.name.indexOf('introduction') >= 0) { +let handleSectionTheme = (currentRoute) => { + if (currentRoute.name.indexOf('introduction') >= 0) { Docs.theme = 'blue'; - } else if (route.name.indexOf('components') >= 0) { + } else if (currentRoute.name.indexOf('components') >= 0) { Docs.theme = 'indigo'; - } else if (route.name.indexOf('themes') >= 0) { + } else if (currentRoute.name.indexOf('themes') >= 0) { Docs.theme = 'teal'; - } else if (route.name.indexOf('ui-elements') >= 0) { + } else if (currentRoute.name.indexOf('ui-elements') >= 0) { Docs.theme = 'blue-grey'; - } else if (route.name.indexOf('changelog') >= 0) { + } else if (currentRoute.name.indexOf('changelog') >= 0) { Docs.theme = 'orange'; - } else if (route.name.indexOf('about') >= 0) { + } else if (currentRoute.name.indexOf('about') >= 0) { Docs.theme = 'green'; } else { Docs.theme = 'default'; @@ -62,7 +62,7 @@ Docs = new Docs({ handleSectionTheme(router.currentRoute); -router.afterEach((currentRoute) => { +router.beforeEach((to, from, next) => { let mainContent = document.querySelector('.main-content'); if (mainContent) { @@ -71,5 +71,7 @@ router.afterEach((currentRoute) => { Docs.closeSidenav(); - handleSectionTheme(currentRoute); + handleSectionTheme(to); + + next(); });