Update:Audio player visible when ereader is open #1800 and adding zoom to PDF reader

This commit is contained in:
advplyr 2023-05-27 11:58:01 -05:00
parent 2cc23b6d6b
commit 2fa73f7a8d
6 changed files with 105 additions and 46 deletions

View file

@ -1,5 +1,5 @@
<template>
<div class="h-full w-full">
<div id="epub-reader" class="h-full w-full">
<div class="h-full flex items-center justify-center">
<div style="width: 100px; max-width: 100px" class="h-full hidden sm:flex items-center overflow-x-hidden justify-center">
<span v-if="hasPrev" class="material-icons text-white text-opacity-50 hover:text-opacity-80 cursor-pointer text-6xl" @mousedown.prevent @click="prev">chevron_left</span>
@ -28,17 +28,24 @@ export default {
libraryItem: {
type: Object,
default: () => {}
}
},
playerOpen: Boolean
},
data() {
return {
windowWidth: 0,
windowHeight: 0,
/** @type {ePub.Book} */
book: null,
/** @type {ePub.Rendition} */
rendition: null
}
},
watch: {
playerOpen() {
this.resize()
}
},
computed: {
/** @returns {string} */
libraryItemId() {
@ -64,6 +71,10 @@ export default {
readerWidth() {
if (this.windowWidth < 640) return this.windowWidth
return this.windowWidth - 200
},
readerHeight() {
if (this.windowHeight < 400 || !this.playerOpen) return this.windowHeight
return this.windowHeight - 164
}
},
methods: {
@ -203,13 +214,13 @@ export default {
/** @type {ePub.Book} */
reader.book = new ePub(reader.url, {
width: this.readerWidth,
height: window.innerHeight - 50
height: this.readerHeight - 50
})
/** @type {ePub.Rendition} */
reader.rendition = reader.book.renderTo('viewer', {
width: this.readerWidth,
height: window.innerHeight * 0.8
height: this.readerHeight * 0.8
})
// load saved progress
@ -253,17 +264,19 @@ export default {
},
resize() {
this.windowWidth = window.innerWidth
this.rendition?.resize(this.readerWidth, window.innerHeight * 0.8)
this.windowHeight = window.innerHeight
this.rendition?.resize(this.readerWidth, this.readerHeight * 0.8)
}
},
mounted() {
this.windowWidth = window.innerWidth
this.windowHeight = window.innerHeight
window.addEventListener('resize', this.resize)
this.initEpub()
},
beforeDestroy() {
window.removeEventListener('resize', this.resize)
this.book?.destroy()
},
mounted() {
this.windowWidth = window.innerWidth
window.addEventListener('resize', this.resize)
this.initEpub()
}
}
</script>