Skip to content

Commit

Permalink
Fix error on destroy when thumbnails view is open
Browse files Browse the repository at this point in the history
When destroying a TIFY instance while the thumbnails panel is open, ResizeObserver could trigger updateDimensions() despite the element being already removed, which led to an error logged to console.
  • Loading branch information
t11r committed Feb 9, 2025
1 parent 2b6b380 commit 54c62e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ViewThumbnails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
itemsPerRow: 0,
knownImages: [],
lastScrollTop: 0,
resizeObserver: null,
resizeTimeout: null,
style: {},
thumbnailWidth: 0,
Expand Down Expand Up @@ -47,12 +48,17 @@ export default {
mounted() {
this.style.flex = this.$el.style.flex;
},
unmounted() {
this.resizeObserver?.disconnect();
clearTimeout(this.resizeTimeout);
},
methods: {
init() {
this.updateDimensions();
this.scrollToCurrentPage(false);
new ResizeObserver(this.onResize).observe(this.$el);
this.resizeObserver = new ResizeObserver(this.onResize);
this.resizeObserver.observe(this.$el);
},
onResize() {
clearTimeout(this.resizeTimeout);
Expand Down

0 comments on commit 54c62e2

Please sign in to comment.