diff --git a/src/digital-components/date-picker/date-picker.vue b/src/digital-components/date-picker/date-picker.vue index 2149a9cd5..b691f575d 100644 --- a/src/digital-components/date-picker/date-picker.vue +++ b/src/digital-components/date-picker/date-picker.vue @@ -60,6 +60,7 @@ v-if="calendarViewDirection === 'future' && !disableViewMoreDatesButton" type="button" class="btn btn-link" + id="viewMoreDates" :disabled="isLoading" @click="showAnotherMonth"> View more dates @@ -615,37 +616,27 @@ export default { }); }); }, - scrollToElement(elementId, speed, easing) { - // TODO - needs to be cleaned up & refactored - function scrollTopSmooth(wrapper, target, duration = 300, timingName = "linear") { - const initY = wrapper.scrollTop; - const wrapperRect = wrapper.getBoundingClientRect(); - const targetRect = target.getBoundingClientRect(); - const targetY = targetRect.top - wrapperRect.top - BUFFER_OFFSET; - const timingFunc = TIMINGFUNC_MAP[timingName]; - let start = null; - - const step = (timestamp) => { - start = start || timestamp; - const progress = timestamp - start, - // Growing from 0 to 1 - time = Math.min(1, (timestamp - start) / duration); - const percentageNew = timingFunc(time); - const distanceToGo = targetY; - const thisDistance = percentageNew * distanceToGo; - - wrapper.scrollTo(0, initY + thisDistance); - if (percentageNew < 1) { - window.requestAnimationFrame(step); - } - }; - window.requestAnimationFrame(step); - } - - const wrapper = document.getElementById("date-picker-fieldset"); - const targetMonth = document.getElementById(elementId); - - scrollTopSmooth(wrapper, targetMonth, 800, "ease-in-out"); + scrollToElement(elementId, duration = 800, easing = "ease-in-out") { + const wrapper = document.querySelector(".page-container-grouped-styles"); + const target = document.getElementById(elementId); + const initY = wrapper.scrollTop; + const wrapperRect = wrapper.getBoundingClientRect(); + const targetRect = target.getBoundingClientRect(); + const targetY = targetRect.top - wrapperRect.top - BUFFER_OFFSET; + const timingFunc = TIMINGFUNC_MAP[easing]; + let start = null; + const step = (timestamp) => { + start = start || timestamp; + const time = Math.min(1, (timestamp - start) / duration); + const percentageNew = timingFunc(time); + const distanceToGo = targetY; + const thisDistance = percentageNew * distanceToGo; + wrapper.scrollTo(0, initY + thisDistance); + if (percentageNew < 1) { + window.requestAnimationFrame(step); + } + }; + window.requestAnimationFrame(step); }, }, components: { @@ -911,9 +902,6 @@ export default { margin-bottom: 0; overflow: hidden; } - &.last-available-month:not(&.month-hidden) { - margin-bottom: 14rem; - } } .btn-link {