CSR-1483: updates to scroll animation
This commit is contained in:
parent
4884027344
commit
3455c685cf
1 changed files with 23 additions and 34 deletions
|
|
@ -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: {
|
||||
|
|
@ -655,6 +646,7 @@ export default {
|
|||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
.date-picker-hidden {
|
||||
opacity: 0;
|
||||
max-height: 0;
|
||||
|
|
@ -911,9 +903,6 @@ export default {
|
|||
margin-bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
&.last-available-month:not(&.month-hidden) {
|
||||
margin-bottom: 14rem;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
|
|
|
|||
Loading…
Reference in a new issue