Skip to content

Commit 963b76d

Browse files
committed
feat: gallery swipe on mobile
1 parent 21b67a6 commit 963b76d

File tree

3 files changed

+149
-1
lines changed

3 files changed

+149
-1
lines changed

frontend/package-lock.json

Lines changed: 134 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lint:stylelint": "stylelint --fix"
2626
},
2727
"dependencies": {
28+
"@vueuse/core": "^10.1.2",
2829
"ace-builds": "^1.22.0",
2930
"audio-recorder-polyfill": "^0.4.1",
3031
"axios": "^1.4.0",

frontend/src/views/GalleryView.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import Chip from 'primevue/chip';
99
import MultiSelect from 'primevue/multiselect';
1010
import Button from 'primevue/button';
1111
import { useConfirm } from 'primevue/useconfirm';
12+
import type { UseSwipeDirection } from '@vueuse/core';
13+
import { useSwipe } from '@vueuse/core';
1214
1315
import socket from '@/utils/socket';
1416
import emitter from '@/services/emitter.service';
@@ -290,6 +292,7 @@ const fixSelectPanel = (value: boolean) => {
290292
291293
const closeModal = () => {
292294
modal.value.show = false;
295+
document.body.style.overflow = 'auto';
293296
setTimeout(() => {
294297
modal.value.src = '';
295298
aspectRatio.value.image = 0;
@@ -397,6 +400,7 @@ onBeforeMount(() => {
397400
if (image && image.filename) {
398401
modal.value.show = true;
399402
modal.value.image = image;
403+
document.body.style.overflow = 'hidden';
400404
}
401405
402406
loadModalImage(image);
@@ -485,6 +489,15 @@ watch(
485489
await getGallery();
486490
},
487491
);
492+
const swipe = ref<HTMLElement | null>(null);
493+
if (window.matchMedia('(pointer: coarse)').matches) {
494+
useSwipe(swipe, {
495+
passive: false,
496+
onSwipeEnd(e: TouchEvent, direction: UseSwipeDirection) {
497+
modalImage(direction === 'left' ? 'next' : 'prev');
498+
},
499+
});
500+
}
488501
</script>
489502

490503
<template>
@@ -513,7 +526,7 @@ watch(
513526
></i>
514527
<i class="fas fa-trash-can" @click="deleteImage(modal.image.id)"></i>
515528
</div>
516-
<img :src="modal.src" class="border-round" />
529+
<img ref="swipe" :src="modal.src" class="border-round" />
517530
<p>{{ modal.summary }}</p>
518531
<div class="text-center chip-wrapper w-full">
519532
<Chip :label="modal.image.meta.ai" class="text-xs mr-2" />

0 commit comments

Comments
 (0)