mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-09-20 21:29:28 +00:00
unobserve if component unmounts
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user