scroll works on other pages

This commit is contained in:
Peter Olu 2022-04-24 16:35:40 +01:00
parent 6b1b71d3cc
commit 98a7a7999c
2 changed files with 10 additions and 5 deletions

View File

@ -31,7 +31,7 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { ref, watch, reactive, defineComponent } from "vue"; import { ref, watch, onMounted, defineComponent } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
@ -50,7 +50,7 @@ export default defineComponent({
components: { ...Configuration, ...controls }, components: { ...Configuration, ...controls },
setup() { setup() {
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const tobewatched = reactive(dashboardStore); // const tobewatched = reactive(dashboardStore);
// const appStore = useAppStoreWithOut(); // const appStore = useAppStoreWithOut();
const { t } = useI18n(); const { t } = useI18n();
const p = useRoute().params; const p = useRoute().params;
@ -58,14 +58,16 @@ export default defineComponent({
// setTemplate(); // setTemplate();
const currentItem = ref(""); const currentItem = ref("");
watch( watch(
() => tobewatched.layout, () => dashboardStore.layout,
() => { () => {
// console.log('Watching:',currentItem.value)
setTimeout(() => { setTimeout(() => {
observeItems(); observeItems();
}, 500); }, 500);
} }
); );
function scrollToGraph(e: any) { function scrollToGraph(e: any) {
console.log(currentItem.value)
document?.getElementById(`item${e}`)?.scrollIntoView(); document?.getElementById(`item${e}`)?.scrollIntoView();
} }
function observeItems() { function observeItems() {
@ -80,6 +82,9 @@ export default defineComponent({
observer.observe(element); observer.observe(element);
}); });
} }
onMounted(()=>{
observeItems()
})
return { return {
t, t,
dashboardStore, dashboardStore,

View File

@ -248,7 +248,7 @@ export default defineComponent({
() => { () => {
setTimeout(() => { setTimeout(() => {
observeItems(); observeItems();
console.log("Last Value:", lastItem.value); // console.log("Last Value:", lastItem.value);
}, 500); }, 500);
} }
); );