From d67454db9aca793be04da4a2745ecabd9608c884 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 25 Feb 2023 16:53:48 -0600 Subject: [PATCH] Fix:Update bookshelf on screen orientation change #602 --- components/bookshelf/LazyBookshelf.vue | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/bookshelf/LazyBookshelf.vue b/components/bookshelf/LazyBookshelf.vue index 47b5b44a..2eede182 100644 --- a/components/bookshelf/LazyBookshelf.vue +++ b/components/bookshelf/LazyBookshelf.vue @@ -452,6 +452,12 @@ export default { this.libraryItemUpdated(ab) }) }, + screenOrientationChange() { + setTimeout(() => { + console.log('LazyBookshelf Screen orientation change') + this.resetEntities() + }, 50) + }, initListeners() { const bookshelf = document.getElementById('bookshelf-wrapper') if (bookshelf) { @@ -466,6 +472,13 @@ export default { this.$socket.$on('item_removed', this.libraryItemRemoved) this.$socket.$on('items_updated', this.libraryItemsUpdated) this.$socket.$on('items_added', this.libraryItemsAdded) + + if (screen.orientation) { + // Not available on ios + screen.orientation.addEventListener('change', this.screenOrientationChange) + } else { + document.addEventListener('orientationchange', this.screenOrientationChange) + } }, removeListeners() { const bookshelf = document.getElementById('bookshelf-wrapper') @@ -481,6 +494,13 @@ export default { this.$socket.$off('item_removed', this.libraryItemRemoved) this.$socket.$off('items_updated', this.libraryItemsUpdated) this.$socket.$off('items_added', this.libraryItemsAdded) + + if (screen.orientation) { + // Not available on ios + screen.orientation.removeEventListener('change', this.screenOrientationChange) + } else { + document.removeEventListener('orientationchange', this.screenOrientationChange) + } } }, updated() {