Add scrolling to surveys from MyActivities page
Resolves MS-902 #complete
This commit is contained in:
parent
b7466d70d1
commit
bc8a84e13a
|
|
@ -2,6 +2,7 @@
|
|||
<div
|
||||
:data-scrollto="value.id"
|
||||
class="survey-block"
|
||||
ref="surveyDiv"
|
||||
>
|
||||
<router-link
|
||||
:to="{ name: 'survey', params: { id: value.id } }"
|
||||
|
|
@ -12,10 +13,35 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['value'],
|
||||
};
|
||||
<script setup lang="ts">
|
||||
import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
export interface Props {
|
||||
value: {
|
||||
id: string;
|
||||
};
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const surveyDiv = ref<HTMLElement | null>(null);
|
||||
const route = useRoute();
|
||||
|
||||
onMounted(() => {
|
||||
if (surveyDiv.value !== null) {
|
||||
if (route.hash === `#${props.value.id}`) {
|
||||
setTimeout(() => {
|
||||
const rect = surveyDiv.value.getBoundingClientRect();
|
||||
|
||||
window.scrollTo({
|
||||
top: rect.y,
|
||||
behavior: 'smooth',
|
||||
});
|
||||
}, PAGE_LOAD_TIMEOUT);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
Loading…
Reference in New Issue