editor view when holding cursor on image + download button with cached data + passing id in url open directly the image

This commit is contained in:
Theophyl Hoguet committed 2023-03-16 01:35:05 +01:00
1 parent 84ba18e150
commit 4d2d3ed5be
2 files changed
+52 -18

No files matched your search

+46 -17
View File
@@ -18,14 +18,18 @@ export default defineComponent({
}, },
data() { data() {
return { return {
imageSelectedId: -1 as number, imageSelectedId: -1,
sure: false as boolean, sure: false,
timer: null as ReturnType<typeof setTimeout> | null, timer: null as ReturnType<typeof setTimeout> | null,
open: false as boolean, open: false,
editor: false
} }
}, },
mounted() { created() {
this.imageSelectedId = this.images.keys().next().value; if (this.$route.params.id)
this.imageSelectedId = parseInt(this.$route.params.id as string);
else
this.imageSelectedId = this.images.keys().next().value;
}, },
watch: { watch: {
images() { images() {
@@ -43,13 +47,11 @@ export default defineComponent({
this.sure = true; this.sure = true;
}, },
startTimer() { startTimer() {
if (this.timer !== null) { if (this.timer !== null)
clearTimeout(this.timer); clearTimeout(this.timer);
this.timer = null;
}
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
location.href = "/images/" + this.imageSelectedId; this.editor = !this.editor;
}, 2500); }, 1900);
}, },
clearTimer() { clearTimer() {
if (this.timer !== null) { if (this.timer !== null) {
@@ -63,9 +65,9 @@ export default defineComponent({
<template> <template>
<div class="flex" v-if="images.keys != null"> <div class="flex" v-if="images.keys != null">
<Image @mouseleave="clearTimer()" @mouseenter="startTimer()" class="home" <Image @mouseleave="clearTimer()" @mouseenter="startTimer()" class="home"
v-if="imageSelectedId !== undefined && imageSelectedId !== -1" :id="imageSelectedId"> v-if="imageSelectedId !== undefined && imageSelectedId !== -1" :id="imageSelectedId" :images="images">
</Image> </Image>
<div class="selector"> <div v-if="!editor" class="selector">
<label>Selectioner une image: </label> <label>Selectioner une image: </label>
<div class="custom-select" :tabindex="imageSelectedId" @blur="open = false"> <div class="custom-select" :tabindex="imageSelectedId" @blur="open = false">
<div class="selected" :class="{ open: open }" @click="open = !open"> <div class="selected" :class="{ open: open }" @click="open = !open">
@@ -77,8 +79,13 @@ export default defineComponent({
</div> </div>
</div> </div>
</div> </div>
<button class="button" @mouseleave="sure = false" @click="confirmDelete()" :class="sure ? 'confirm' : ''"> <button class="button" @mouseleave="sure = false" @click="confirmDelete()" :class="{ confirm: sure }">
{{ sure ? "Confirmer" : "Supprimer" }}</button> {{ sure ? "Confirmer" : "Supprimer" }}</button>
<a class="button" :href="images.get(imageSelectedId)?.data"
:download="images.get(imageSelectedId)?.name">Télécharger</a>
</div>
<div v-else>
</div> </div>
</div> </div>
<h1 v-else>Aucune image trouvée</h1> <h1 v-else>Aucune image trouvée</h1>
@@ -156,6 +163,10 @@ export default defineComponent({
/* FIN SELECT */ /* FIN SELECT */
a {
text-decoration: none;
}
html { html {
overflow: hidden; overflow: hidden;
} }
@@ -191,13 +202,31 @@ label {
} }
</style> </style>
<style> <style>
.home img { .home.imageContainer {
max-width: 60%; max-width: 60%;
max-height: 60vh; max-height: 60vh;
} }
.home img:hover { div.home.imageContainer:hover {
transform: scale(2); animation: zoom-in-zoom-out 2s cubic-bezier(1, 0, 0.51, 1.01);
transition: transform 3s; transform: none;
}
@keyframes zoom-in-zoom-out {
0% {
transform: scale(1);
}
60% {
transform: scale(1.5);
}
75% {
transform: scale(10);
}
100% {
transform: none;
}
} }
</style> </style>
+6 -1
View File
@@ -4,7 +4,7 @@ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes: [ routes: [
{ {
path: '/', path: '/:id(\\d)?',
name: 'home', name: 'home',
component: () => import('../components/Home.vue') component: () => import('../components/Home.vue')
}, },
@@ -17,6 +17,11 @@ const router = createRouter({
path: '/upload', path: '/upload',
name: "upload", name: "upload",
component: () => import('../components/Upload.vue') component: () => import('../components/Upload.vue')
},
{
path: '/:pathMatch(.*)*',
name: 'not-found',
component: () => import('../components/NotFound.vue')
} }
] ]
}) })