From e2b0ccc74a1ec1e4942fb1a243b22172994662aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 31 Jan 2018 16:18:59 +0100 Subject: [PATCH] example: Rename scroll-behavior example --- .../custom-scroll-behavior/nuxt.config.js | 48 ------------------- .../README.md | 0 .../assets/main.css | 0 examples/scroll-behavior/nuxt.config.js | 6 +++ .../package.json | 0 .../pages/about.vue | 0 .../pages/about/contact.vue | 0 .../pages/about/profile.vue | 0 .../pages/index.vue | 0 .../pages/long.vue | 0 .../pages/users.vue | 0 11 files changed, 6 insertions(+), 48 deletions(-) delete mode 100644 examples/custom-scroll-behavior/nuxt.config.js rename examples/{custom-scroll-behavior => scroll-behavior}/README.md (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/assets/main.css (100%) create mode 100644 examples/scroll-behavior/nuxt.config.js rename examples/{custom-scroll-behavior => scroll-behavior}/package.json (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/pages/about.vue (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/pages/about/contact.vue (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/pages/about/profile.vue (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/pages/index.vue (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/pages/long.vue (100%) rename examples/{custom-scroll-behavior => scroll-behavior}/pages/users.vue (100%) diff --git a/examples/custom-scroll-behavior/nuxt.config.js b/examples/custom-scroll-behavior/nuxt.config.js deleted file mode 100644 index 8bb892dad3..0000000000 --- a/examples/custom-scroll-behavior/nuxt.config.js +++ /dev/null @@ -1,48 +0,0 @@ -const scrollBehavior = function (to, from, savedPosition) { - // if the returned position is falsy or an empty object, - // will retain current scroll position. - let position = false - - // if no children detected - if (to.matched.length < 2) { - // scroll to the top of the page - position = { x: 0, y: 0 } - } else if (to.matched.some((r) => r.components.default.options.scrollToTop)) { - // if one of the children has scrollToTop option set to true - position = { x: 0, y: 0 } - } - - // savedPosition is only available for popstate navigations (back button) - if (savedPosition) { - position = savedPosition - } - - return new Promise(resolve => { - // wait for the out transition to complete (if necessary) - this.app.$root.$once('triggerScroll', () => { - // coords will be used if no selector is provided, - // or if the selector didn't match any element. - if (to.hash && document.querySelector(to.hash)) { - // scroll to anchor by returning the selector - position = { selector: to.hash } - } - - resolve(position) - }) - }) -} - -module.exports = { - build: { - vendor: ['axios'] - }, - css: ['~/assets/main.css'], - transition: { - beforeEnter() { - this.$root.$emit('triggerScroll') - } - }, - router: { - scrollBehavior - } -} diff --git a/examples/custom-scroll-behavior/README.md b/examples/scroll-behavior/README.md similarity index 100% rename from examples/custom-scroll-behavior/README.md rename to examples/scroll-behavior/README.md diff --git a/examples/custom-scroll-behavior/assets/main.css b/examples/scroll-behavior/assets/main.css similarity index 100% rename from examples/custom-scroll-behavior/assets/main.css rename to examples/scroll-behavior/assets/main.css diff --git a/examples/scroll-behavior/nuxt.config.js b/examples/scroll-behavior/nuxt.config.js new file mode 100644 index 0000000000..c4264e9c56 --- /dev/null +++ b/examples/scroll-behavior/nuxt.config.js @@ -0,0 +1,6 @@ +module.exports = { + build: { + vendor: ['axios'] + }, + css: ['~/assets/main.css'] +} diff --git a/examples/custom-scroll-behavior/package.json b/examples/scroll-behavior/package.json similarity index 100% rename from examples/custom-scroll-behavior/package.json rename to examples/scroll-behavior/package.json diff --git a/examples/custom-scroll-behavior/pages/about.vue b/examples/scroll-behavior/pages/about.vue similarity index 100% rename from examples/custom-scroll-behavior/pages/about.vue rename to examples/scroll-behavior/pages/about.vue diff --git a/examples/custom-scroll-behavior/pages/about/contact.vue b/examples/scroll-behavior/pages/about/contact.vue similarity index 100% rename from examples/custom-scroll-behavior/pages/about/contact.vue rename to examples/scroll-behavior/pages/about/contact.vue diff --git a/examples/custom-scroll-behavior/pages/about/profile.vue b/examples/scroll-behavior/pages/about/profile.vue similarity index 100% rename from examples/custom-scroll-behavior/pages/about/profile.vue rename to examples/scroll-behavior/pages/about/profile.vue diff --git a/examples/custom-scroll-behavior/pages/index.vue b/examples/scroll-behavior/pages/index.vue similarity index 100% rename from examples/custom-scroll-behavior/pages/index.vue rename to examples/scroll-behavior/pages/index.vue diff --git a/examples/custom-scroll-behavior/pages/long.vue b/examples/scroll-behavior/pages/long.vue similarity index 100% rename from examples/custom-scroll-behavior/pages/long.vue rename to examples/scroll-behavior/pages/long.vue diff --git a/examples/custom-scroll-behavior/pages/users.vue b/examples/scroll-behavior/pages/users.vue similarity index 100% rename from examples/custom-scroll-behavior/pages/users.vue rename to examples/scroll-behavior/pages/users.vue