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
|
<div
|
||||||
:data-scrollto="value.id"
|
:data-scrollto="value.id"
|
||||||
class="survey-block"
|
class="survey-block"
|
||||||
|
ref="surveyDiv"
|
||||||
>
|
>
|
||||||
<router-link
|
<router-link
|
||||||
:to="{ name: 'survey', params: { id: value.id } }"
|
:to="{ name: 'survey', params: { id: value.id } }"
|
||||||
|
|
@ -12,10 +13,35 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
export default {
|
import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts';
|
||||||
props: ['value'],
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue