Fix scrolling to assignments

This commit is contained in:
Ramon Wenger 2019-12-18 13:18:17 +01:00
parent cb13aa1ea5
commit b132e320af
2 changed files with 3 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="assignment"> <div class="assignment" :data-scrollto="assignment.id">
<p class="assignment__assignment-text"> <p class="assignment__assignment-text">
{{assignment.assignment}} {{assignment.assignment}}
</p> </p>

View File

@ -46,7 +46,7 @@
if (mutation.type === 'setScrollToAssignmentReady' && mutation.payload && !this.isScrollingToAssignment) { if (mutation.type === 'setScrollToAssignmentReady' && mutation.payload && !this.isScrollingToAssignment) {
this.scrollingToAssignment(true); this.scrollingToAssignment(true);
let options = { let options = {
container: '#app', container: 'body',
easing: 'ease', easing: 'ease',
offset: -60, offset: -60,
onStart: (element) => { onStart: (element) => {
@ -62,7 +62,7 @@
y: true y: true
}; };
setTimeout(() => { setTimeout(() => {
this.$scrollTo(`#${this.scrollToAssignmentId.replace(/=/g, '')}`, 1000, options); this.$scrollTo(`[data-scrollto="${this.scrollToAssignmentId}"]`, 1000, options);
}, 250) // unfortunately this timeout is needed as it is hard to tell when everything is rendered }, 250) // unfortunately this timeout is needed as it is hard to tell when everything is rendered
} }
}) })