From 23a900a23577dc2bd3e8e6be02f49856b491c099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Viguier?= Date: Wed, 27 Nov 2024 16:11:43 +0100 Subject: [PATCH] Fix photo timeline when there are no borders (#2746) --- .../js/components/gallery/PhotoThumbPanel.vue | 18 ++++++++++++++++++ .../components/gallery/PhotoThumbPanelList.vue | 13 +++++++++++-- resources/js/layouts/PhotoLayout.ts | 9 +++++++-- resources/js/layouts/useJustify.ts | 9 ++++++--- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/resources/js/components/gallery/PhotoThumbPanel.vue b/resources/js/components/gallery/PhotoThumbPanel.vue index 9739d22fa7b..5b14eeb1ef6 100644 --- a/resources/js/components/gallery/PhotoThumbPanel.vue +++ b/resources/js/components/gallery/PhotoThumbPanel.vue @@ -34,6 +34,24 @@ +
+ +
diff --git a/resources/js/components/gallery/PhotoThumbPanelList.vue b/resources/js/components/gallery/PhotoThumbPanelList.vue index 00321c4f383..1204913637c 100644 --- a/resources/js/components/gallery/PhotoThumbPanelList.vue +++ b/resources/js/components/gallery/PhotoThumbPanelList.vue @@ -13,9 +13,11 @@ diff --git a/resources/js/layouts/PhotoLayout.ts b/resources/js/layouts/PhotoLayout.ts index 756103a6ccd..2e4e9603c18 100644 --- a/resources/js/layouts/PhotoLayout.ts +++ b/resources/js/layouts/PhotoLayout.ts @@ -5,10 +5,15 @@ import { useMasonry } from "./useMasonry"; import { useGrid } from "./useGrid"; import AlbumService from "@/services/album-service"; +export type TimelineData = { + isTimeline: Ref; + isLeftBorderVisible: Ref; +}; + export function useLayouts( config: App.Http.Resources.GalleryConfigs.PhotoLayoutConfig, layout: Ref, - isTimeline: Ref, + timelineData: TimelineData, elemId: string = "photoListing", ) { const configRef = ref(config); @@ -25,7 +30,7 @@ export function useLayouts( return useSquare(photoListing, configRef.value.photo_layout_square_column_width, configRef.value.photo_layout_gap); case "justified": case "unjustified": - return useJustify(photoListing, configRef.value.photo_layout_justified_row_height, isTimeline.value); + return useJustify(photoListing, configRef.value.photo_layout_justified_row_height, timelineData); case "masonry": return useMasonry(photoListing, configRef.value.photo_layout_masonry_column_width, configRef.value.photo_layout_gap); case "grid": diff --git a/resources/js/layouts/useJustify.ts b/resources/js/layouts/useJustify.ts index e59e6a13374..8f1ebb006c1 100644 --- a/resources/js/layouts/useJustify.ts +++ b/resources/js/layouts/useJustify.ts @@ -1,13 +1,16 @@ +import { TimelineData } from "./PhotoLayout"; import { ChildNodeWithDataStyle } from "./types"; import createJustifiedLayout from "justified-layout"; -export function useJustify(el: HTMLElement, photoDefaultHeight: number = 320, isTimeline: boolean) { +export function useJustify(el: HTMLElement, photoDefaultHeight: number = 320, timelineData: TimelineData) { const baseElem = document.getElementById("lychee_view_content"); if (!baseElem) { return; } - const containerDefaultWidth = parseInt(getComputedStyle(baseElem).width) - 86; - const containerWidth = isTimeline ? Math.min(parseInt(getComputedStyle(el).width), containerDefaultWidth) : parseInt(getComputedStyle(el).width); + const containerDefaultWidth = parseInt(getComputedStyle(baseElem).width) - 36 - (timelineData.isLeftBorderVisible ? 50 : 0); + const containerWidth = timelineData.isTimeline + ? Math.min(parseInt(getComputedStyle(el).width), containerDefaultWidth) + : parseInt(getComputedStyle(el).width); // @ts-expect-error const justifiedItems: ChildNodeWithDataStyle[] = [...el.childNodes].filter((gridItem) => gridItem.nodeType === 1);