Skip to content

Commit

Permalink
feat: replace my scrollTo with smoothScroll mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
BoulderBrains committed Nov 12, 2021
1 parent a6bd9a4 commit 79b48e2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/components/BorrowerProfile/JumpLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@

<script>
import { mdiAccount, mdiFormatListBulleted } from '@mdi/js';
import smoothScrollMixin from '@/plugins/smooth-scroll-mixin';
import KvMaterialIcon from '~/@kiva/kv-components/vue/KvMaterialIcon';
export default {
components: {
KvMaterialIcon,
},
mixins: [smoothScrollMixin],
data() {
return {
mdiAccount,
Expand All @@ -44,12 +46,7 @@ export default {
scrollToSection(sectionId) {
const elementToScrollTo = document.querySelector(sectionId);
const topOfSectionToScrollTo = elementToScrollTo?.offsetTop ?? 0;
window.scrollTo({
// 50 (to compensate for the height of the top nav) + top of the section to be scrolled to
// leaves the user on the correct section of the page when a jump link is clicked
top: 50 + topOfSectionToScrollTo,
behavior: 'smooth'
});
this.smoothScrollTo({ yPosition: topOfSectionToScrollTo, millisecondsToAnimate: 750 });
}
}
};
Expand Down

0 comments on commit 79b48e2

Please sign in to comment.