mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 03:59:04 -08:00
* small changes in asset viewer navigation * add conditional wrapper and scroll only content * fix formatting * update conditional wrapper * remove emptz title attribute * remove conditional-wrapper as it is not needed * remove isTimeline * fix map over sidebar * fix overlap * fix conflict * revert z-index * add relative z index --------- Co-authored-by: faupau03 <paul.paffe@gmx.net>
81 lines
2.2 KiB
Svelte
81 lines
2.2 KiB
Svelte
<script lang="ts">
|
|
import type { PageData } from '../map/$types';
|
|
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
|
|
import Portal from '$lib/components/shared-components/portal/portal.svelte';
|
|
import AssetViewer from '$lib/components/asset-viewer/asset-viewer.svelte';
|
|
import {
|
|
assetInteractionStore,
|
|
isViewingAssetStoreState,
|
|
viewingAssetStoreState
|
|
} from '$lib/stores/asset-interaction.store';
|
|
|
|
export let data: PageData;
|
|
|
|
let initialMapCenter: [number, number] = [48, 11];
|
|
|
|
$: {
|
|
if (data.mapMarkers.length) {
|
|
let firstMarker = data.mapMarkers[0];
|
|
initialMapCenter = [firstMarker.lat, firstMarker.lon];
|
|
}
|
|
}
|
|
|
|
let viewingAssets: string[] = [];
|
|
let viewingAssetCursor = 0;
|
|
|
|
function onViewAssets(assets: string[]) {
|
|
assetInteractionStore.setViewingAssetId(assets[0]);
|
|
viewingAssets = assets;
|
|
viewingAssetCursor = 0;
|
|
}
|
|
|
|
function navigateNext() {
|
|
if (viewingAssetCursor < viewingAssets.length - 1) {
|
|
assetInteractionStore.setViewingAssetId(viewingAssets[++viewingAssetCursor]);
|
|
}
|
|
}
|
|
|
|
function navigatePrevious() {
|
|
if (viewingAssetCursor > 0) {
|
|
assetInteractionStore.setViewingAssetId(viewingAssets[--viewingAssetCursor]);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<UserPageLayout user={data.user} title={data.meta.title}>
|
|
<div slot="buttons" />
|
|
|
|
<div class="h-[90%] w-full relative z-0">
|
|
{#await import('$lib/components/shared-components/leaflet') then { Map, TileLayer, AssetMarkerCluster }}
|
|
<Map latlng={initialMapCenter} zoom={7}>
|
|
<TileLayer
|
|
allowDarkMode={true}
|
|
urlTemplate={'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'}
|
|
options={{
|
|
attribution:
|
|
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
}}
|
|
/>
|
|
<AssetMarkerCluster
|
|
markers={data.mapMarkers}
|
|
on:view={(event) => onViewAssets(event.detail.assets)}
|
|
/>
|
|
</Map>
|
|
{/await}
|
|
</div>
|
|
</UserPageLayout>
|
|
|
|
<Portal target="body">
|
|
{#if $isViewingAssetStoreState}
|
|
<AssetViewer
|
|
asset={$viewingAssetStoreState}
|
|
showNavigation={viewingAssets.length > 1}
|
|
on:navigate-next={navigateNext}
|
|
on:navigate-previous={navigatePrevious}
|
|
on:close={() => {
|
|
assetInteractionStore.setIsViewingAsset(false);
|
|
}}
|
|
/>
|
|
{/if}
|
|
</Portal>
|