forked from verdnatura/salix-front
perf: remove setTimeOut insteaduse requestAnimationFrame
This commit is contained in:
parent
dcbb0da8c0
commit
98b8124577
|
@ -78,17 +78,16 @@ watch(
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
const onItemSaved = (updatedItem) => {
|
const onItemSaved = (updatedItem) => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
scrollToItem(updatedItem.items[0].itemFk);
|
scrollToItem(updatedItem.items[0].itemFk);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollToItem = async (id) => {
|
const scrollToItem = async (id) => {
|
||||||
await nextTick();
|
|
||||||
setTimeout(() => {
|
|
||||||
const element = itemRefs.value[id]?.$el;
|
const element = itemRefs.value[id]?.$el;
|
||||||
if (element) {
|
if (element) {
|
||||||
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
}
|
}
|
||||||
}, 100);
|
|
||||||
};
|
};
|
||||||
provide('onItemSaved', onItemSaved);
|
provide('onItemSaved', onItemSaved);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue