mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 17:05:10 +00:00
unobserve if component unmounts
This commit is contained in:
parent
29b5a8fd97
commit
a082fce977
@ -205,7 +205,7 @@ export default defineComponent({
|
||||
document?.getElementById(`tabitem${e}`)?.scrollIntoView();
|
||||
}
|
||||
|
||||
function observeItems() {
|
||||
function observeItems(kill = false) {
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
entries.forEach(
|
||||
(element) => {
|
||||
@ -224,6 +224,11 @@ export default defineComponent({
|
||||
document.querySelectorAll(".tabitem").forEach((element) => {
|
||||
observer.observe(element);
|
||||
});
|
||||
if (kill) {
|
||||
document.querySelectorAll(".tabitem").forEach((element) => {
|
||||
observer.unobserve(element);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
@ -319,7 +324,7 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
observeItems.unobserve();
|
||||
observeItems(true);
|
||||
});
|
||||
return {
|
||||
currentItem,
|
||||
|
Loading…
Reference in New Issue
Block a user