diff --git a/frontend/src/components/files/ExtendedImage.vue b/frontend/src/components/files/ExtendedImage.vue
index d0bc1bf9..4e0d3aac 100644
--- a/frontend/src/components/files/ExtendedImage.vue
+++ b/frontend/src/components/files/ExtendedImage.vue
@@ -52,7 +52,7 @@ export default {
lastY: null,
inDrag: false,
touches: 0,
- navOffset: 50,
+ navThreshold: 50,
lastTouchDistance: 0,
moveDisabled: false,
disabledTimer: null,
@@ -92,7 +92,7 @@ export default {
const wScale = window.innerWidth / img.clientWidth
const hScale = window.innerHeight / img.clientHeight
- this.scale = wScale < hScale? wScale: hScale
+ this.scale = Math.min(wScale, hScale)
this.minScale = this.scale
this.setZoom()
},
@@ -117,32 +117,31 @@ export default {
let x = 0,y = 0
// left out of viewport
- if (rect.left < 0 && rect.right < width) x = width - rect.right
-
+ if (rect.left < 0 && rect.right < width) x = Math.min(-rect.left, width - rect.right)
// right out of viewport
- else if (rect.left > 0 && rect.right > width) x = -rect.left
+ else if (rect.left > 0 && rect.right > width) x = Math.min(-rect.left, width - rect.right)
// top out of viewport
- if (rect.top < 0 && rect.bottom < height) y = height - rect.bottom
+ if (rect.top < 0 && rect.bottom < height) y = Math.min(-rect.top, height - rect.bottom)
// bottom out of viewport
- else if (rect.top > 0 && rect.bottom > height) y = -rect.top
+ else if (rect.top > 0 && rect.bottom > height) y = Math.min(-rect.top, height - rect.bottom)
return [x,y]
}
},
checkNav(x) {
if (this.scale <= this.minScale) {
- if (x > this.navOffset) this.$root.$emit('gallery-nav', 0)
- else if (x < -this.navOffset) this.$root.$emit('gallery-nav', 1)
+ if (x > this.navThreshold) this.$root.$emit('gallery-nav', 0)
+ else if (x < -this.navThreshold) this.$root.$emit('gallery-nav', 1)
} else {
let img = this.$refs.imgex
const rect = img.getBoundingClientRect()
const width = window.innerWidth
- if (rect.left > this.navOffset && rect.right > width + this.navOffset) this.$root.$emit('gallery-nav', 0)
- else if (rect.left < - this.navOffset && rect.right < width - this.navOffset) this.$root.$emit('gallery-nav', 1)
+ if (x > this.navThreshold && rect.left > this.navThreshold && rect.right > width + this.navThreshold) this.$root.$emit('gallery-nav', 0)
+ else if (x < -this.navThreshold && rect.left < - this.navThreshold && rect.right < width - this.navThreshold) this.$root.$emit('gallery-nav', 1)
}
},
onLoad() {
@@ -214,18 +213,8 @@ export default {
event.preventDefault()
},
zoomAuto(event) {
- switch (this.scale) {
- case 1:
- this.scale = 2
- break
- case 2:
- this.scale = 4
- break
- default:
- case 4:
- this.scale = 1
- break
- }
+ if (this.minScale <= this.scale && this.scale < 2 * this.minScale) this.scale *= 2
+ else this.scale /= 2
this.setZoom()
event.preventDefault()
},
@@ -300,6 +289,7 @@ export default {
this.scale = this.scale < this.minScale ? this.minScale : this.scale
this.scale = this.scale > this.maxScale ? this.maxScale : this.scale
this.$refs.imgex.style.transform = `scale(${this.scale})`
+ this.refit()
},
pxStringToNumber(style) {
return +style.replace("px", "")
diff --git a/frontend/src/components/files/ImagePreview.vue b/frontend/src/components/files/ImagePreview.vue
deleted file mode 100644
index c40d1460..00000000
--- a/frontend/src/components/files/ImagePreview.vue
+++ /dev/null
@@ -1,218 +0,0 @@
-
-
-
-
-
-
{{ this.name }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/src/components/files/Preview.vue b/frontend/src/components/files/Preview.vue
index 7b69fe48..360939cf 100644
--- a/frontend/src/components/files/Preview.vue
+++ b/frontend/src/components/files/Preview.vue
@@ -1,13 +1,13 @@
-
+
{{ this.name }}
-
+
@@ -37,7 +37,8 @@
-
+
+
-
@@ -33,8 +32,8 @@ import Forbidden from './errors/403'
import NotFound from './errors/404'
import InternalError from './errors/500'
import Preview from '@/components/files/Preview'
-import ImagePreview from "@/components/files/ImagePreview"
import Listing from '@/components/files/Listing'
+import Editor from '@/components/files/Editor'
import { files as api } from '@/api'
import { mapGetters, mapState, mapMutations } from 'vuex'
@@ -45,13 +44,12 @@ function clean (path) {
export default {
name: 'files',
components: {
- ImagePreview,
Forbidden,
NotFound,
InternalError,
Preview,
Listing,
- Editor: () => import('@/components/files/Editor')
+ Editor
},
computed: {
...mapGetters([
@@ -68,11 +66,8 @@ export default {
'loading',
'show'
]),
- isImagePreview () {
- return (!this.loading && !this.isListing && !this.isEditor || this.loading && this.$store.state.previewMode) && this.req.type === 'image'
- },
isPreview () {
- return (!this.loading && !this.isListing && !this.isEditor || this.loading && this.$store.state.previewMode) && this.req.type !== 'image'
+ return !this.loading && !this.isListing && !this.isEditor || this.loading && this.$store.state.previewMode
},
breadcrumbs () {
let parts = this.$route.path.split('/')