Skip to content

Commit

Permalink
feat: core-236 adding smoothScroll to disclaimers anchor click
Browse files Browse the repository at this point in the history
  • Loading branch information
BoulderBrains committed Nov 12, 2021
1 parent ecbbf0a commit 1e5fcfa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/WwwFrame/DisclaimersContentful.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
s<template>
<template>
<div class="row">
<ol id="disclaimers" class="text-left">
<li
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<h3 class="appeal-banner__title strong" v-html="headline"></h3>
<a
v-if="disclaimer"
href="#disclaimers"
@click="scrollToSection('#disclaimers')"
class="appeal-banner__disclaimer-indicator"
v-kv-track-event="['promo', 'click-Contentful-banner', 'disclaimer-superscript', '1']"
>
Expand Down Expand Up @@ -138,6 +138,7 @@
<script>
// import numeral from 'numeral';
import smoothReflow from 'vue-smooth-reflow';
import smoothScrollMixin from '@/plugins/smooth-scroll-mixin';
import KvButton from '@/components/Kv/KvButton';
import KvIcon from '@/components/Kv/KvIcon';
Expand All @@ -151,7 +152,7 @@ export default {
KvProgressCircle,
KvContentfulImg
},
mixins: [smoothReflow],
mixins: [smoothReflow, smoothScrollMixin],
props: {
targetAmount: {
type: Number,
Expand Down Expand Up @@ -217,6 +218,11 @@ export default {
onClickToggleBanner() {
this.$emit('toggle-banner', !this.isOpen);
},
scrollToSection(sectionId) {
const elementToScrollTo = document.querySelector(sectionId);
const topOfSectionToScrollTo = elementToScrollTo?.offsetTop ?? 0;
this.smoothScrollTo({ yPosition: topOfSectionToScrollTo, millisecondsToAnimate: 750 });
}
},
mounted() {
this.$smoothReflow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</component>
<a
v-if="hasDisclaimer"
href="#disclaimers"
@click="scrollToSection('#disclaimers')"
class="disclaimer-indicator"
v-kv-track-event="['promo', 'click-Contentful-banner', 'disclaimer-superscript', '1']"
>
Expand All @@ -27,11 +27,13 @@

<script>
import KvIcon from '@/components/Kv/KvIcon';
import smoothScrollMixin from '@/plugins/smooth-scroll-mixin';
export default {
components: {
KvIcon
},
mixins: [smoothScrollMixin],
props: {
iconKey: {
type: String,
Expand All @@ -49,6 +51,13 @@ export default {
}
},
},
methods: {
scrollToSection(sectionId) {
const elementToScrollTo = document.querySelector(sectionId);
const topOfSectionToScrollTo = elementToScrollTo?.offsetTop ?? 0;
this.smoothScrollTo({ yPosition: topOfSectionToScrollTo, millisecondsToAnimate: 750 });
}
},
computed: {
// if the promoBannerContent includes a link, render a router-link element, else render a plain div
currentWrapperComponent() {
Expand Down

0 comments on commit 1e5fcfa

Please sign in to comment.