fix: clear timers and animation frame request before component unmounts (#8700)

Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
Arooba Shahoor
2024-01-22 15:38:33 +09:00
committed by GitHub
parent fd4376d062
commit b3c9d1f1a5
3 changed files with 17 additions and 2 deletions

View File

@@ -60,6 +60,7 @@ export default {
scrollPosition: 0,
ticking: true,
disableBranding: window.chatwootWebChannel.disableBranding || false,
requestID: null,
};
},
computed: {
@@ -120,6 +121,7 @@ export default {
},
beforeDestroy() {
this.$el.removeEventListener('scroll', this.updateScrollPosition);
cancelAnimationFrame(this.requestID);
},
methods: {
closeWindow() {
@@ -128,7 +130,7 @@ export default {
updateScrollPosition(event) {
this.scrollPosition = event.target.scrollTop;
if (!this.ticking) {
window.requestAnimationFrame(() => {
this.requestID = window.requestAnimationFrame(() => {
this.ticking = false;
});