Init lightboxu az po otevreni fotky
This commit is contained in:
@@ -6,8 +6,9 @@ import PhotoSwipeDynamicCaption from "../../../node_modules/photoswipe-dynamic-c
|
|||||||
import PhotoCaption from "components/photos/PhotoCaption.vue";
|
import PhotoCaption from "components/photos/PhotoCaption.vue";
|
||||||
import PhotoSwipeLightbox from "../../../node_modules/photoswipe/dist/photoswipe-lightbox.esm"
|
import PhotoSwipeLightbox from "../../../node_modules/photoswipe/dist/photoswipe-lightbox.esm"
|
||||||
import PhotoSwipe from "../../../node_modules/photoswipe/dist/photoswipe.esm"
|
import PhotoSwipe from "../../../node_modules/photoswipe/dist/photoswipe.esm"
|
||||||
import {useRoute, useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import {usePhotosStore} from "stores/Photos";
|
import {usePhotosStore} from "stores/Photos";
|
||||||
|
import {useQuasar} from "quasar";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
galleryId: {
|
galleryId: {
|
||||||
@@ -21,9 +22,8 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const $router = useRouter();
|
const $router = useRouter();
|
||||||
|
const $q = useQuasar();
|
||||||
|
|
||||||
let $lightbox = ref(null);
|
let $lightbox = ref(null);
|
||||||
|
|
||||||
@@ -46,18 +46,15 @@ const initLightbox = () => {
|
|||||||
$lightbox.value.init();
|
$lightbox.value.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isCollapsed = ref(true);
|
||||||
|
const photosCollapseLimit = computed(() => {
|
||||||
|
if ($q.screen.width <= $q.screen.sizes.sm) return 2;
|
||||||
|
else if ($q.screen.width <= $q.screen.sizes.md) return 3;
|
||||||
|
else return 4;
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
initLightbox();
|
isCollapsed.value = props.photos.length >= photosCollapseLimit.value;
|
||||||
|
|
||||||
// todo: tohle nefunguje, sice se galerie zavre, ale i tak se user presmeruje na predchozi stranku
|
|
||||||
window.onpopstate = function (e) {
|
|
||||||
if (!$lightbox.value || !$lightbox.value.pswp) {
|
|
||||||
initLightbox();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($lightbox.value && $lightbox.value.pswp)
|
|
||||||
$lightbox.value.pswp.close();
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
@@ -69,7 +66,11 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
const openedPhoto = computed(() => usePhotosStore().openedPhoto);
|
const openedPhoto = computed(() => usePhotosStore().openedPhoto);
|
||||||
watch(() => [openedPhoto.value, $lightbox.value], () => {
|
watch(() => [openedPhoto.value, $lightbox.value], () => {
|
||||||
if (!$lightbox.value || !openedPhoto.value) return;
|
if (!openedPhoto.value) return;
|
||||||
|
|
||||||
|
if (!$lightbox.value) {
|
||||||
|
initLightbox();
|
||||||
|
}
|
||||||
|
|
||||||
const idx = props.photos.findIndex(p => p.id === openedPhoto.value.id);
|
const idx = props.photos.findIndex(p => p.id === openedPhoto.value.id);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
@@ -77,47 +78,73 @@ watch(() => [openedPhoto.value, $lightbox.value], () => {
|
|||||||
usePhotosStore().setOpenedPhoto(null);
|
usePhotosStore().setOpenedPhoto(null);
|
||||||
}
|
}
|
||||||
}, {immediate: true});
|
}, {immediate: true});
|
||||||
|
|
||||||
const isCollapsed = ref(false);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :id="galleryId" :class="{row: true, collapsed: isCollapsed}">
|
<div :class="{'photogallery--wrapper': true, collapsed: isCollapsed}" :id="`${galleryId}-wrapper`">
|
||||||
<div
|
<div :id="galleryId" class="row photogallery--content">
|
||||||
v-for="photo in photos" :key="photo.id"
|
<div
|
||||||
style="min-height: 100px"
|
v-for="photo in photos" :key="photo.id"
|
||||||
class="col-6 col-sm-4 col-md-4 col-lg-3 q-pa-sm"
|
style="min-height: 100px"
|
||||||
>
|
class="col-6 col-sm-4 col-md-4 col-lg-3 q-pa-sm"
|
||||||
<a
|
|
||||||
:href="photo.url"
|
|
||||||
:data-pswp-width="photo.width"
|
|
||||||
:data-pswp-height="photo.height"
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
>
|
>
|
||||||
<q-img
|
<a
|
||||||
spinner-color="primary"
|
:data-pswp-src="photo.url"
|
||||||
class="rounded-borders"
|
:data-pswp-width="photo.width"
|
||||||
:src="photo.thumbnailUrl"
|
:data-pswp-height="photo.height"
|
||||||
alt=""
|
target="_blank"
|
||||||
|
@click="initLightbox"
|
||||||
|
rel="noreferrer"
|
||||||
>
|
>
|
||||||
<div class="absolute-bottom" v-if="photo.name !== ''">
|
<q-img
|
||||||
{{ photo.name }}
|
spinner-color="primary"
|
||||||
</div>
|
class="rounded-borders"
|
||||||
</q-img>
|
:src="photo.thumbnailUrl"
|
||||||
<PhotoCaption :photo="photo"/>
|
alt=""
|
||||||
</a>
|
>
|
||||||
|
<div class="absolute-bottom" v-if="photo.name !== ''">
|
||||||
|
{{ photo.name }}
|
||||||
|
</div>
|
||||||
|
</q-img>
|
||||||
|
<PhotoCaption :photo="photo"/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a class="photogallery--collapse" v-if="isCollapsed" @click="isCollapsed = false">
|
||||||
|
<q-btn class="q-mt-lg q-mb-md" color="secondary">Rozbalit</q-btn>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <q-btn @click="isCollapsed=!isCollapsed">{{isCollapsed ? 'Sbalit' : "Rozbalit"}}</q-btn>-->
|
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
.collapsed {
|
.photogallery--wrapper {
|
||||||
max-height: 50px;
|
margin: 50px 0;
|
||||||
overflow: hidden
|
|
||||||
|
a:hover {
|
||||||
|
cursor: pointer
|
||||||
|
}
|
||||||
|
|
||||||
|
&.collapsed {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.photogallery--content {
|
||||||
|
max-height: 250px;
|
||||||
|
overflow: hidden
|
||||||
|
}
|
||||||
|
|
||||||
|
.photogallery--collapse {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
text-align: center;
|
||||||
|
background: rgb(255, 255, 255);
|
||||||
|
background: linear-gradient(0deg, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 35%, rgba(255, 255, 255, 0) 100%);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: predelat na usePagination() composable!
|
||||||
|
|
||||||
export const paginationLimit = ref(10);
|
export const paginationLimit = ref(10);
|
||||||
export const paginationOffset = ref(0);
|
export const paginationOffset = ref(0);
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ useMeta(() => metaData({
|
|||||||
|
|
||||||
<q-no-ssr>
|
<q-no-ssr>
|
||||||
<q-inner-loading v-if="arePhotosLoading"/>
|
<q-inner-loading v-if="arePhotosLoading"/>
|
||||||
<PhotoGallery :photos="flightPhotos" v-else/>
|
<PhotoGallery :photos="flightPhotos" v-else-if="!arePhotosLoading && flightPhotos.length > 0"/>
|
||||||
<FlightTrackMap :key="flight.id" :flight="flight" :photos="flightPhotos"/>
|
<FlightTrackMap :key="flight.id" :flight="flight" :photos="flightPhotos"/>
|
||||||
</q-no-ssr>
|
</q-no-ssr>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|||||||
Reference in New Issue
Block a user