From 08e73747bd440f19d0dd8e3cfa5baaa22f9fd6c0 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 1 Oct 2019 17:29:49 +0200 Subject: [PATCH] refactor: set global defaults of vue-scrollto --- webapp/components/Comment/Comment.spec.js | 2 +- webapp/components/CommentList/CommentList.spec.js | 2 +- webapp/mixins/scrollToAnchor.js | 2 +- webapp/nuxt.config.js | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/webapp/components/Comment/Comment.spec.js b/webapp/components/Comment/Comment.spec.js index 9dc16777e..59e3f6c5a 100644 --- a/webapp/components/Comment/Comment.spec.js +++ b/webapp/components/Comment/Comment.spec.js @@ -145,7 +145,7 @@ describe('Comment.vue', () => { it('calls $scrollTo', () => { wrapper = Wrapper() jest.runAllTimers() - expect(mocks.$scrollTo).toHaveBeenCalledWith('#commentId-2', 1000) + expect(mocks.$scrollTo).toHaveBeenCalledWith('#commentId-2') }) }) }) diff --git a/webapp/components/CommentList/CommentList.spec.js b/webapp/components/CommentList/CommentList.spec.js index 0eacf8628..3287b7cd4 100644 --- a/webapp/components/CommentList/CommentList.spec.js +++ b/webapp/components/CommentList/CommentList.spec.js @@ -103,7 +103,7 @@ describe('CommentList.vue', () => { it('calls $scrollTo', () => { wrapper = Wrapper() jest.runAllTimers() - expect(mocks.$scrollTo).toHaveBeenCalledWith('#comments', 1000) + expect(mocks.$scrollTo).toHaveBeenCalledWith('#comments') }) }) }) diff --git a/webapp/mixins/scrollToAnchor.js b/webapp/mixins/scrollToAnchor.js index 70a1bf695..2966c79ed 100644 --- a/webapp/mixins/scrollToAnchor.js +++ b/webapp/mixins/scrollToAnchor.js @@ -5,7 +5,7 @@ function scrollToAnchor(anchor, { checkAnchor, $scrollTo }) { ) if (!checkAnchor(anchor)) return setTimeout(() => { - $scrollTo(anchor, 1000) + $scrollTo(anchor) }, 250) } diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index 4867ad5d6..84602f7eb 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -142,7 +142,13 @@ export default { keys: envWhitelist, }, ], - 'vue-scrollto/nuxt', + [ + 'vue-scrollto/nuxt', + { + offset: -100, // to compensate fixed navbar height + duration: 1000, + }, + ], 'cookie-universal-nuxt', '@nuxtjs/apollo', '@nuxtjs/axios',