-
+
+
+
+
-
@@ -54,6 +60,10 @@ import Path from 'path'
import { Archive } from 'libarchive.js/main.js'
import { CompressedFile } from 'libarchive.js/src/compressed-file'
+// This is % with respect to the screen width
+const MAX_SCALE = 400
+const MIN_SCALE = 10
+
Archive.init({
workerUrl: '/libarchive/worker-bundle.js'
})
@@ -81,7 +91,8 @@ export default {
showInfoMenu: false,
loadTimeout: null,
loadedFirstPage: false,
- comicMetadata: null
+ comicMetadata: null,
+ scale: 80
}
},
watch: {
@@ -136,6 +147,12 @@ export default {
return p
}) || []
)
+ },
+ canScaleUp() {
+ return this.scale < MAX_SCALE
+ },
+ canScaleDown() {
+ return this.scale > MIN_SCALE
}
},
methods: {
@@ -331,10 +348,37 @@ export default {
orderedImages = orderedImages.concat(noNumImages.map((i) => i.filename))
this.pages = orderedImages
+ },
+ zoomIn() {
+ this.scale += 10
+ },
+ zoomOut() {
+ this.scale -= 10
+ },
+ scroll(event) {
+ const imageContainer = this.$refs.imageContainer
+
+ imageContainer.scrollBy({
+ top: event.deltaY,
+ left: event.deltaX,
+ behavior: 'auto'
+ })
}
},
- mounted() {},
- beforeDestroy() {}
+ mounted() {
+ const prevButton = this.$refs.prevButton
+ const nextButton = this.$refs.nextButton
+
+ prevButton.addEventListener('wheel', this.scroll, { passive: false })
+ nextButton.addEventListener('wheel', this.scroll, { passive: false })
+ },
+ beforeDestroy() {
+ const prevButton = this.$refs.prevButton
+ const nextButton = this.$refs.nextButton
+
+ prevButton.removeEventListener('wheel', this.scroll, { passive: false })
+ nextButton.removeEventListener('wheel', this.scroll, { passive: false })
+ }
}