Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
feat(frontend): image viewer redesign (#290)
Johan Legrandaa2e988db7d5
diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.htmlindex 835096ba..bfbefb32 100644--- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html+++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.html@@ -26,7 +26,7 @@@switch (activeViewer()) {@case (SHORT_MIME.IMAGE) {@defer (on immediate) {- <app-files-viewer-image [currentHeight]="currentHeight" [(file)]="currentFile" [directoryImages]="directoryImages()"></app-files-viewer-image>+ <app-files-viewer-image [(file)]="currentFile" [directoryImages]="directoryImages()"></app-files-viewer-image>} @loading (after 100ms; minimum 200ms) {<ng-container [ngTemplateOutlet]="viewerLoading"></ng-container>} @error {diff --git a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.tsindex bf3d6e86..77426690 100644--- a/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts+++ b/frontend/src/app/applications/files/components/dialogs/files-viewer-dialog.component.ts@@ -60,7 +60,7 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy {ngOnInit() {this.canToggleViewer = this.isWriteable && !!this.currentFile?.isEditable && this.hookedShortMime === SHORT_MIME.PDFthis.activeViewer.set(this.hookedShortMime)- this.isReadonly.set(this.hookedShortMime === SHORT_MIME.PDF || this.mode === FILE_MODE.VIEW)+ this.isReadonly.set(this.hookedShortMime === SHORT_MIME.PDF || this.mode === FILE_MODE.VIEW || !this.currentFile.isEditable)this.openedFile = { id: this.currentFile.id, name: this.currentFile.name, mimeUrl: this.currentFile.mimeUrl }this.onResize()}@@ -88,6 +88,9 @@ export class FilesViewerDialogComponent implements OnInit, OnDestroy {@HostListener('window:beforeunload', ['$event'])onBeforeUnload(event: BeforeUnloadEvent) {+ const activeViewer = this.activeViewer()+ if (activeViewer === SHORT_MIME.IMAGE || activeViewer === SHORT_MIME.PDF) return+event.preventDefault()event.returnValue = ''}diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.html b/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.htmlindex 18e7d2cd..88528a97 100644--- a/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.html+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.html@@ -1,80 +1,219 @@-<div class="app-top-menu app-top-menu-tool-bar d-flex justify-content-between"- [attr.aria-label]="'Actions' | translate:locale.language"- role="toolbar">- <div class="d-flex">- <button- (click)="previousImage()"- [attr.aria-label]="'Previous' | translate:locale.language"- [tooltip]="'Previous' | translate:locale.language"- [adaptivePosition]="true"- class="btn btn-custom"- type="button">- <svg [lucideIcon]="icons.LucideChevronLeft"></svg>- </button>- <button- (click)="nextImage()"- [attr.aria-label]="'Next' | translate:locale.language"- [tooltip]="'Next' | translate:locale.language"- class="btn btn-custom"- type="button">- <svg [lucideIcon]="icons.LucideChevronRight"></svg>- </button>- @if (!isSlideshowActive()) {- <button- (click)="startSlideshow()"- [attr.aria-label]="'Start Slideshow' | translate:locale.language"- [tooltip]="'Start Slideshow' | translate:locale.language"- class="btn btn-custom"- type="button">- <svg [lucideIcon]="icons.LucidePlay"></svg>- </button>+@let currentFile = file();+@let galleryOpen = isGalleryOpen();+<div #viewer+ class="app-viewer-image"+ (keydown.escape)="onViewerEscape($event)"+ (pointerenter)="onViewerPointerMove($event)"+ (pointermove)="onViewerPointerMove($event)"+ (pointerleave)="onViewerPointerLeave($event)">+ <div #canvas+ class="app-viewer-image-canvas"+ (pointerdown)="onGesturePointerDown($event)"+ (pointermove)="onGesturePointerMove($event)"+ (pointerup)="onGesturePointerUp($event)"+ (pointercancel)="onGesturePointerCancel($event)"+ [attr.aria-busy]="galleryOpen ? null : isImageLoading()"+ [attr.aria-label]="galleryOpen ? ('Gallery' | translate:locale.language) : null"+ [attr.role]="galleryOpen ? 'region' : null"+ [attr.tabindex]="galleryOpen ? -1 : null"+ [class.is-gallery]="galleryOpen">+ @if (galleryOpen) {+ @let failedThumbnailIds = galleryFailedThumbnailIds();+ <div+ (touchstart)="onGalleryMultiTouch($event)"+ class="app-viewer-image-gallery">+ @for (galleryFile of directoryImages(); track galleryFile.id) {+ @let thumbnailUrl = galleryFile.thumbnailUrl;+ <button+ (click)="selectGalleryImage(galleryFile)"+ [attr.aria-current]="galleryFile.id === currentFile.id ? 'true' : null"+ [attr.aria-label]="galleryFile.name"+ [attr.data-gallery-file-id]="galleryFile.id"+ [class.is-current]="galleryFile.id === currentFile.id"+ class="app-viewer-image-gallery-item"+ type="button">+ @if (failedThumbnailIds.has(galleryFile.id)) {+ <span class="app-viewer-image-gallery-fallback">{{ galleryFile.name }}</span>+ } @else {+ <img+ (error)="onGalleryThumbnailError(galleryFile.id)"+ [attr.srcset]="thumbnailUrl + '?size=256 1x, ' + thumbnailUrl + '?size=512 2x'"+ [src]="thumbnailUrl + '?size=256'"+ alt=""+ class="app-viewer-image-gallery-thumbnail"+ decoding="async"+ draggable="false"+ height="200"+ loading="lazy"+ width="300" />+ }+ </button>+ }+ </div>} @else {- <button- (click)="stopSlideshow()"- [attr.aria-label]="'Stop slideshow' | translate:locale.language"- [tooltip]="'Stop slideshow' | translate:locale.language"- class="btn btn-custom"- type="button">- <svg [lucideIcon]="icons.LucideSquare"></svg>- </button>+ <img #image+ (error)="onImageError()"+ (load)="onImageLoad()"+ (wheel)="onImageWheel($event)"+ [alt]="currentFile.name"+ [class.is-pannable]="isImagePannable()"+ [class.is-panning]="isImagePanning()"+ [src]="currentFile.dataUrl"+ [style.transform]="imageTransform()"+ class="app-viewer-image-media"+ decoding="async"+ draggable="false"+ fetchpriority="high" />+ @if (isImageLoading()) {+ <div class="app-viewer-image-loader"+ [attr.aria-label]="'Loading...' | translate:locale.language"+ role="status">+ <svg [lucideIcon]="icons.LucideLoader" class="app-viewer-image-loader-icon icon-spin-pulse" aria-hidden="true"></svg>+ </div>+ }}- <button- (click)="fullscreen()"- [attr.aria-label]="'Fullscreen' | translate:locale.language"- [tooltip]="'Fullscreen' | translate:locale.language"- class="btn btn-custom"- type="button">- <svg [lucideIcon]="icons.LucideExpand"></svg>- </button></div>- <div class="px-2">{{ imageIndex() + 1 }}<span class="px-1" l10nTranslate>of</span>{{ imageCount() }}</div>- <button- btnCheckbox- [attr.aria-label]="'Info' | translate:locale.language"- [(ngModel)]="isInfoboxOpen"- [tooltip]="'Info' | translate:locale.language"- class="d-none d-sm-block btn btn-custom"- type="button">- <svg [lucideIcon]="icons.LucideInfo"></svg>- </button>-</div>-<div class="app-viewer-image" [style.height.px]="currentHeightWithOffset()">- <img #image- (load)="onImageLoad()"- [src]="file().dataUrl" [style.max-height.px]="currentHeightWithOffset()"- alt="" />- <div class="info-box p-2 m-2 d-flex flex-column app-small-card rounded opacity-75" [class.d-none]="!isInfoboxOpen()">- <div class="d-flex mb-1">- <div class="d-flex col-sm text-bold">{{ 'Type' | translate:locale.language }}</div>- <div>{{ file().mime }}</div>- </div>- <div class="d-flex mb-1">- <div class="d-flex col-sm text-bold">{{ 'Dimensions' | translate:locale.language }}</div>- <div>{{ imageResolution() }}</div>+ <div class="app-viewer-image-controls"+ (pointerdown)="onControlsPointerDown($event)"+ (pointerenter)="onControlsPointerEnter($event)"+ (pointerleave)="onControlsPointerLeave($event)"+ [attr.aria-label]="'Actions' | translate:locale.language"+ [class.is-controls-hidden]="!isControlsVisible()"+ role="toolbar">+ <div class="app-viewer-image-controls-group app-viewer-image-controls-navigation">+ <button+ (click)="previousImage()"+ [attr.aria-label]="'Previous' | translate:locale.language"+ [tooltip]="'Previous' | translate:locale.language"+ [adaptivePosition]="true"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="icons.LucideChevronLeft" aria-hidden="true"></svg>+ </button>+ <span class="app-viewer-image-counter"+ aria-live="polite">+ <span>{{ imageIndex() + 1 }}</span>+ <span class="app-viewer-image-counter-separator">/</span>+ <span>{{ imageCount() }}</span>+ </span>+ <button+ (click)="nextImage()"+ [attr.aria-label]="'Next' | translate:locale.language"+ [tooltip]="'Next' | translate:locale.language"+ [adaptivePosition]="true"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="icons.LucideChevronRight" aria-hidden="true"></svg>+ </button></div>- <div class="d-flex mb-1">- <div class="d-flex col-sm text-bold">{{ 'Size' | translate:locale.language }}</div>- <div>{{ file().hSize }}</div>+ @if (!galleryOpen) {+ <span class="app-viewer-image-controls-separator" aria-hidden="true"></span>+ <div class="app-viewer-image-controls-group app-viewer-image-controls-transform">+ <button+ (click)="zoomOut($event)"+ [attr.aria-label]="'Zoom out' | translate:locale.language"+ [disabled]="!canZoomOut()"+ [tooltip]="'Zoom out' | translate:locale.language"+ class="app-viewer-image-control app-viewer-image-control-zoom"+ type="button">+ <svg [lucideIcon]="icons.LucideZoomOut" aria-hidden="true"></svg>+ </button>+ <button+ (click)="zoomIn($event)"+ [attr.aria-label]="'Zoom in' | translate:locale.language"+ [disabled]="!canZoomIn()"+ [tooltip]="'Zoom in' | translate:locale.language"+ class="app-viewer-image-control app-viewer-image-control-zoom"+ type="button">+ <svg [lucideIcon]="icons.LucideZoomIn" aria-hidden="true"></svg>+ </button>+ <button+ (click)="resetImageTransform()"+ [attr.aria-label]="'Reset' | translate:locale.language"+ [tooltip]="'Reset' | translate:locale.language"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="icons.LucideFocus" aria-hidden="true"></svg>+ </button>+ <button+ (click)="rotateLeft()"+ [attr.aria-label]="'Rotate left' | translate:locale.language"+ [tooltip]="'Rotate left' | translate:locale.language"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="icons.LucideRotateCcwSquare" aria-hidden="true"></svg>+ </button>+ <button+ (click)="rotateRight()"+ [attr.aria-label]="'Rotate right' | translate:locale.language"+ [tooltip]="'Rotate right' | translate:locale.language"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="icons.LucideRotateCwSquare" aria-hidden="true"></svg>+ </button>+ </div>+ }+ <span class="app-viewer-image-controls-separator" aria-hidden="true"></span>+ <div class="app-viewer-image-controls-group app-viewer-image-controls-actions">+ @if (imageCount() > 1) {+ <button+ (click)="toggleGallery()"+ [attr.aria-label]="'Gallery' | translate:locale.language"+ [attr.aria-pressed]="galleryOpen"+ [tooltip]="'Gallery' | translate:locale.language"+ class="app-viewer-image-control app-viewer-image-control-gallery"+ type="button">+ <svg [lucideIcon]="icons.LucideGrid2x2" aria-hidden="true"></svg>+ </button>+ }+ @if (!galleryOpen && imageCount() > 1) {+ @let slideshow = slideshowAction();+ <button+ (click)="toggleSlideshow()"+ [attr.aria-label]="slideshow.label | translate:locale.language"+ [attr.aria-pressed]="isSlideshowActive()"+ [class.is-slideshow-active]="isSlideshowActive()"+ [tooltip]="slideshow.label | translate:locale.language"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="slideshow.icon" aria-hidden="true"></svg>+ </button>+ }+ <button+ (click)="fullscreen()"+ [attr.aria-label]="'Fullscreen' | translate:locale.language"+ [tooltip]="'Fullscreen' | translate:locale.language"+ class="app-viewer-image-control"+ type="button">+ <svg [lucideIcon]="icons.LucideExpand" aria-hidden="true"></svg>+ </button>+ @if (!galleryOpen) {+ <button+ (click)="toggleInfobox()"+ [attr.aria-label]="'Info' | translate:locale.language"+ [attr.aria-pressed]="isInfoboxOpen()"+ [tooltip]="'Info' | translate:locale.language"+ class="app-viewer-image-control app-viewer-image-control-info"+ type="button">+ <svg [lucideIcon]="icons.LucideInfo" aria-hidden="true"></svg>+ </button>+ }</div></div>+ @if (isInfoboxOpen()) {+ <dl class="info-box">+ <div class="info-box-row">+ <dt>{{ 'Type' | translate:locale.language }}</dt>+ <dd>{{ currentFile.mime }}</dd>+ </div>+ <div class="info-box-row">+ <dt>{{ 'Dimensions' | translate:locale.language }}</dt>+ <dd>{{ imageResolution() }}</dd>+ </div>+ <div class="info-box-row">+ <dt>{{ 'Size' | translate:locale.language }}</dt>+ <dd>{{ currentFile.hSize }}</dd>+ </div>+ </dl>+ }</div>diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.scss b/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.scssnew file mode 100644index 00000000..3b977db4--- /dev/null+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.scss@@ -0,0 +1,389 @@+.app-viewer-image {+ position: relative;+ display: flex;+ height: calc(100vh - var(--modal-header-height));+ height: calc(100dvh - var(--modal-header-height));+ background-color: #28353b;+ touch-action: pan-y;++ &:fullscreen {+ width: 100vw;+ height: 100vh !important;+ }++ .app-viewer-image-canvas {+ display: flex;+ justify-content: center;+ width: 100%;+ height: 100%;+ overflow: hidden;+ touch-action: none;++ &.is-gallery {+ display: block;+ box-sizing: border-box;+ padding: .25rem .25rem 5rem;+ overflow-x: hidden;+ overflow-y: auto;+ overscroll-behavior: contain;+ scrollbar-gutter: stable;+ touch-action: pan-y;+ }+ }++ .app-viewer-image-gallery {+ --gallery-item-width: 14rem;+ --gallery-item-height: 9.333rem;++ display: grid;+ grid-template-columns: repeat(auto-fill, var(--gallery-item-width));+ grid-auto-rows: var(--gallery-item-height);+ align-content: start;+ justify-content: center;+ gap: .375rem;+ width: 100%;+ min-height: 100%;+ }++ .app-viewer-image-gallery-item {+ position: relative;+ display: block;+ padding: 0;+ margin: 0;+ overflow: hidden;+ border: 0;+ border-radius: .375rem;+ color: rgba(255, 255, 255, .88);+ background-color: rgba(18, 22, 23, .86);+ font: inherit;+ cursor: pointer;+ appearance: none;+ scroll-margin: 1rem;+ contain: layout paint style;+ contain-intrinsic-size: var(--gallery-item-width) var(--gallery-item-height);+ content-visibility: auto;++ &.is-current::after {+ position: absolute;+ inset: 0;+ z-index: 1;+ content: '';+ box-shadow: inset 0 0 0 3px #ff8a00;+ pointer-events: none;+ }++ &:focus-visible {+ z-index: 2;+ outline: 2px solid #fff;+ outline-offset: -3px;+ }+ }++ .app-viewer-image-gallery-thumbnail,+ .app-viewer-image-gallery-fallback {+ width: 100%;+ height: 100%;+ }++ .app-viewer-image-gallery-thumbnail {+ display: block;+ object-fit: cover;+ transition: transform .16s ease-out, filter .16s ease-out;+ user-select: none;+ -webkit-user-drag: none;+ }++ .app-viewer-image-gallery-fallback {+ display: flex;+ align-items: center;+ justify-content: center;+ padding: .75rem;+ overflow: hidden;+ font-size: .75rem;+ overflow-wrap: anywhere;+ text-align: center;+ }++ .app-viewer-image-media {+ display: block;+ align-self: center;+ max-width: 100%;+ max-height: 100%;+ height: auto;+ user-select: none;+ transform-origin: center;+ will-change: transform;+ -webkit-user-drag: none;++ &.is-panning {+ cursor: grabbing;+ }+ }++ .app-viewer-image-loader {+ position: absolute;+ top: 0;+ left: 0;+ z-index: 3;+ display: flex;+ align-items: center;+ justify-content: center;+ width: 100%;+ height: 100%;+ pointer-events: none;+ }++ .app-viewer-image-loader-icon {+ width: 1.5rem;+ height: 1.5rem;+ color: #fff;+ }++ .app-viewer-image-controls,+ .info-box {+ border: 1px solid rgba(255, 255, 255, .16);+ color: rgba(255, 255, 255, .88);+ background-color: rgba(18, 22, 23, .86);+ box-shadow: 0 .35rem 1.25rem rgba(0, 0, 0, .3);+ -webkit-backdrop-filter: blur(.5rem);+ backdrop-filter: blur(.5rem);+ }++ .app-viewer-image-controls {+ position: absolute;+ z-index: 2;+ display: flex;+ align-items: center;+ justify-content: center;+ bottom: 1rem;+ left: 50%;+ gap: .125rem;+ max-width: calc(100% - 1rem);+ padding: .35rem .5rem;+ border-radius: 999px;+ opacity: 1;+ transform: translateX(-50%);+ transition: opacity .16s ease-out, transform .16s ease-out;+ will-change: opacity, transform;++ &.is-controls-hidden {+ opacity: 0;+ pointer-events: none;+ transform: translate(-50%, .5rem);+ transition-duration: .32s;+ transition-timing-function: ease-in;+ }++ &:has(:focus-visible) {+ opacity: 1;+ pointer-events: auto;+ transform: translateX(-50%);+ transition-duration: .16s;+ transition-timing-function: ease-out;+ }+ }++ .app-viewer-image-controls-group {+ display: flex;+ align-items: center;+ gap: .125rem;+ }++ .app-viewer-image-controls-navigation {+ gap: .375rem;+ }++ .app-viewer-image-control {+ display: inline-flex;+ flex: 0 0 auto;+ align-items: center;+ justify-content: center;+ width: 2.75rem;+ height: 2.75rem;+ padding: 0;+ margin: 0;+ border: 0;+ border-radius: 50%;+ color: inherit;+ background-color: transparent;+ font: inherit;+ line-height: 1;+ text-align: center;+ text-decoration: none;+ cursor: pointer;+ user-select: none;+ appearance: none;++ > .lucide {+ font-size: 1.25rem;+ }++ &:active,+ &:focus-visible,+ &[aria-pressed='true'] {+ color: #fff;+ background-color: rgba(255, 255, 255, .14);+ }++ &:focus-visible {+ outline: 2px solid rgba(255, 255, 255, .8);+ outline-offset: -2px;+ box-shadow: none;+ }++ &:disabled {+ opacity: .65;+ pointer-events: none;+ }++ &.app-viewer-image-control-gallery[aria-pressed='true'] > .lucide,+ &.is-slideshow-active > .lucide {+ color: #ff8a00;+ }+ }++ .app-viewer-image-counter {+ display: inline-flex;+ flex-shrink: 0;+ align-items: center;+ justify-content: center;+ gap: .25rem;+ min-width: 3.25rem;+ font-weight: 400;+ line-height: 1;+ text-align: center;+ user-select: none;+ white-space: nowrap;+ font-variant-numeric: tabular-nums;+ }++ .app-viewer-image-counter-separator {+ color: rgba(255, 255, 255, .55);+ }++ .app-viewer-image-controls-separator {+ display: block;+ flex-shrink: 0;+ width: 1px;+ height: 1.5rem;+ margin-right: .25rem;+ margin-left: .25rem;+ background-color: rgba(255, 255, 255, .22);+ }++ @media (hover: hover) and (pointer: fine) {+ .app-viewer-image-control:hover {+ color: #fff;+ background-color: rgba(255, 255, 255, .14);+ }++ .app-viewer-image-gallery-item:hover .app-viewer-image-gallery-thumbnail {+ filter: brightness(1.08);+ transform: scale(1.025);+ }++ .app-viewer-image-media.is-pannable:not(.is-panning) {+ cursor: grab;+ }+ }++ @media (prefers-reduced-motion: reduce) {+ .app-viewer-image-controls,+ .app-viewer-image-gallery-thumbnail {+ transition: none;+ }+ }++ .info-box {+ position: absolute;+ top: .75rem;+ right: .75rem;+ z-index: 1;+ width: min(19.375rem, calc(100% - 1rem));+ margin: 0;+ padding: .5rem;+ border-radius: .375rem;++ .info-box-row {+ display: grid;+ grid-template-columns: minmax(0, 1fr) minmax(0, auto);+ align-items: start;+ gap: 1rem;++ + .info-box-row {+ margin-top: .25rem;+ }+ }++ dt {+ font-weight: 600;+ }++ dd {+ min-width: 0;+ margin: 0;+ overflow-wrap: anywhere;+ text-align: right;+ }+ }++ @media (max-width: 575.98px) {+ .app-viewer-image-gallery {+ grid-template-columns: repeat(2, minmax(0, 1fr));+ grid-auto-rows: auto;+ justify-content: stretch;+ }++ .app-viewer-image-gallery-item {+ aspect-ratio: 3 / 2;+ }++ .app-viewer-image-controls {+ display: grid;+ bottom: .5rem;+ grid-template-columns: auto auto;+ gap: .125rem .5rem;+ border-radius: 1.75rem;+ }++ .app-viewer-image-control {+ width: 2.5rem;+ height: 2.5rem;+ }++ .app-viewer-image-control-zoom,+ .app-viewer-image-control-info,+ .app-viewer-image-controls-separator {+ display: none;+ }++ .app-viewer-image-counter {+ min-width: 3rem;+ }++ .app-viewer-image-controls-navigation {+ grid-row: 1;+ grid-column: 1 / -1;+ justify-content: center;+ }++ .app-viewer-image-controls-transform {+ grid-row: 2;+ grid-column: 1;+ }++ .app-viewer-image-controls-actions {+ grid-row: 2;+ grid-column: 2;+ }++ .app-viewer-image-controls:not(:has(.app-viewer-image-controls-transform)) .app-viewer-image-controls-actions {+ grid-column: 1 / -1;+ justify-self: center;+ }++ .info-box {+ display: none;+ }+ }+}diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.tsindex 11d74229..d6d85f0d 100755--- a/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.ts+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-image.component.ts@@ -1,61 +1,790 @@-import { ChangeDetectionStrategy, Component, computed, DestroyRef, ElementRef, inject, input, model, signal, viewChild } from '@angular/core'-import { takeUntilDestroyed } from '@angular/core/rxjs-interop'-import { FormsModule } from '@angular/forms'-import { LucideChevronLeft, LucideChevronRight, LucideDynamicIcon, LucideExpand, LucideInfo, LucidePlay, LucideSquare } from '@lucide/angular'-import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'-import { ButtonCheckboxDirective } from 'ngx-bootstrap/buttons'+import {+ afterNextRender,+ ChangeDetectionStrategy,+ Component,+ computed,+ DestroyRef,+ type ElementRef,+ inject,+ input,+ model,+ signal,+ viewChild+} from '@angular/core'+import {+ LucideChevronLeft,+ LucideChevronRight,+ LucideDynamicIcon,+ LucideExpand,+ LucideFocus,+ LucideGrid2x2,+ LucideInfo,+ LucideLoader,+ LucidePlay,+ LucideRotateCcwSquare,+ LucideRotateCwSquare,+ LucideSquare,+ LucideZoomIn,+ LucideZoomOut+} from '@lucide/angular'+import { L10N_LOCALE, type L10nLocale, L10nTranslatePipe } from 'angular-l10n'import { TooltipModule } from 'ngx-bootstrap/tooltip'-import { Subscription, timer } from 'rxjs'-import { FileModel } from '../../models/file.model'+import type { FileModel } from '../../models/file.model'@Component({selector: 'app-files-viewer-image',- imports: [FormsModule, TooltipModule, LucideDynamicIcon, ButtonCheckboxDirective, L10nTranslatePipe, L10nTranslateDirective],+ imports: [TooltipModule, LucideDynamicIcon, L10nTranslatePipe],+ styleUrl: 'files-viewer-image.component.scss',templateUrl: 'files-viewer-image.component.html',changeDetection: ChangeDetectionStrategy.OnPush})export class FilesViewerImageComponent {- file = model.required<FileModel>()- directoryImages = input.required<FileModel[]>()- currentHeight = input.required<number>()- currentHeightWithOffset = computed(() => this.currentHeight() - 40)- protected isInfoboxOpen = signal(false)- protected isSlideshowActive = signal(false)- protected imageCount = computed(() => this.directoryImages().length)- protected imageIndex = computed(() => this.directoryImages().indexOf(this.file()))- protected imageResolution = signal<string>('')- protected readonly icons = { LucideChevronLeft, LucideChevronRight, LucideExpand, LucideInfo, LucidePlay, LucideSquare }+ readonly file = model.required<FileModel>()+ readonly directoryImages = input.required<FileModel[]>()+ protected readonly galleryFailedThumbnailIds = signal<ReadonlySet<number>>(new Set())+ protected readonly isInfoboxOpen = signal(false)+ protected readonly isGalleryOpen = signal(false)+ protected readonly isSlideshowActive = signal(false)+ protected readonly imageCount = computed(() => this.directoryImages().length)+ protected readonly imageIndex = computed(() => {+ const currentFileId = this.file().id+ return this.directoryImages().findIndex(({ id }) => id === currentFileId)+ })+ protected readonly imageResolution = signal('')+ protected readonly imageScale = signal(1)+ protected readonly imageRotation = signal(0)+ protected readonly imageOffsetX = signal(0)+ protected readonly imageOffsetY = signal(0)+ protected readonly isImagePannable = signal(false)+ protected readonly isImagePanning = signal(false)+ protected readonly isImageLoading = signal(true)+ protected readonly isControlsVisible = signal(true)+ protected readonly imageTransform = computed(+ () => `translate3d(${this.imageOffsetX()}px, ${this.imageOffsetY()}px, 0) rotate(${this.imageRotation()}deg) scale(${this.imageScale()})`+ )+ protected readonly canZoomIn = computed(() => this.imageScale() < this.imageZoomMax)+ protected readonly canZoomOut = computed(() => this.imageScale() > this.imageZoomMin)+ protected readonly icons = {+ LucideChevronLeft,+ LucideChevronRight,+ LucideExpand,+ LucideFocus,+ LucideGrid2x2,+ LucideInfo,+ LucideLoader,+ LucideRotateCcwSquare,+ LucideRotateCwSquare,+ LucideZoomIn,+ LucideZoomOut+ }+ protected readonly slideshowAction = computed(() =>+ this.isSlideshowActive() ? { icon: LucideSquare, label: 'Stop slideshow' } : { icon: LucidePlay, label: 'Start Slideshow' }+ )protected readonly locale = inject<L10nLocale>(L10N_LOCALE)+ private readonly imageZoomMin = 0.5+ private readonly imageZoomMax = 8+ private readonly imageZoomStepThreshold = 2+ private readonly imageZoomFineStep = 0.5+ private readonly imageZoomCoarseStep = 1+ private readonly imageRotationStep = 90+ private readonly controlsIdleDelay = 2500+ private readonly imageLoadingMinDuration = 250+ private readonly imageWheelThreshold = 40private readonly slideDelay = 5000- private destroyRef = inject(DestroyRef)- private imageRef = viewChild.required<ElementRef>('image')- private slideshowSub: Subscription+ private readonly swipeThreshold = 50+ private readonly activeTouchPointers = new Map<number, PointerEvent>()+ private readonly canvasRef = viewChild.required<ElementRef<HTMLElement>>('canvas')+ private readonly destroyRef = inject(DestroyRef)+ private readonly imageRef = viewChild<ElementRef<HTMLImageElement>>('image')+ private readonly viewerRef = viewChild.required<ElementRef<HTMLElement>>('viewer')+ private controlsHovered = false+ private controlsIdleDeadline = 0+ private controlsIdleTimer: ReturnType<typeof setTimeout> | null = null+ private galleryRenderTimer: ReturnType<typeof setTimeout> | null = null+ private returnToGalleryOnEscape = false+ private imageLoadingStartedAt = Date.now()+ private imageLoadingTimer: ReturnType<typeof setTimeout> | null = null+ private imageWheelDelta = 0+ private imageZoomAnchorClientX: number | null = null+ private imageZoomAnchorClientY: number | null = null+ private panPointerId: number | null = null+ private panStartX = 0+ private panStartY = 0+ private panOriginX = 0+ private panOriginY = 0+ private pinchCanvasCenterX = 0+ private pinchCanvasCenterY = 0+ private pinchStartCenterX = 0+ private pinchStartCenterY = 0+ private pinchStartDistance: number | null = null+ private pinchStartOffsetX = 0+ private pinchStartOffsetY = 0+ private pinchStartScale = 1+ private slideshowTimer: ReturnType<typeof setInterval> | null = null+ private swipePointerId: number | null = null+ private swipeStartX: number | null = null+ private swipeStartY: number | null = null++ constructor() {+ this.scheduleControlsHide()+ this.destroyRef.onDestroy(() => {+ this.clearControlsIdleTimer()+ this.clearGalleryRenderTimer()+ this.clearImageLoadingTimer()+ this.clearSlideshowTimer()+ })+ afterNextRender(() => {+ const canvas = this.canvasRef().nativeElement+ const galleryGestureListenerOptions: AddEventListenerOptions = { capture: true, passive: false }+ const preventGalleryGesture = (event: Event) => {+ // Safari gesture events are not part of Angular's template event typings.+ if (this.isGalleryOpen() && event.cancelable) event.preventDefault()+ }+ const resizeObserver = new ResizeObserver(() => {+ if (!this.isGalleryOpen()) this.clampCurrentImagePosition()+ })+ canvas.addEventListener('gesturestart', preventGalleryGesture, galleryGestureListenerOptions)+ canvas.addEventListener('gesturechange', preventGalleryGesture, galleryGestureListenerOptions)+ resizeObserver.observe(canvas)+ this.destroyRef.onDestroy(() => {+ canvas.removeEventListener('gesturestart', preventGalleryGesture, galleryGestureListenerOptions)+ canvas.removeEventListener('gesturechange', preventGalleryGesture, galleryGestureListenerOptions)+ resizeObserver.disconnect()+ })+ })+ }protected onImageLoad() {- const img = this.imageRef().nativeElement+ const img = this.imageRef()?.nativeElement+ if (!img) return+this.imageResolution.set(`${img.naturalWidth}x${img.naturalHeight}`)+ this.clampCurrentImagePosition()+ this.finishImageLoading()+ }++ protected onImageError() {+ this.isImagePannable.set(false)+ this.finishImageLoading()}protected nextImage() {- this.file.set(this.directoryImages()[(this.imageIndex() + 1) % this.imageCount()])+ this.showImageAtOffset(1)}protected previousImage() {- this.file.set(this.directoryImages()[(this.imageCount() + this.imageIndex() - 1) % this.imageCount()])+ this.showImageAtOffset(-1)+ }++ protected toggleGallery() {+ if (this.isGalleryOpen()) {+ this.returnToGalleryOnEscape = false+ this.showImageView()+ } else {+ this.openGallery()+ }+ }++ private openGallery() {+ if (this.imageCount() < 2) return++ this.stopSlideshow()+ this.cancelActiveGesture()+ this.clearImageLoadingTimer()+ this.isInfoboxOpen.set(false)+ this.imageWheelDelta = 0+ this.clearImageZoomAnchor()+ this.returnToGalleryOnEscape = true+ this.isGalleryOpen.set(true)+ this.showControlsTemporarily()+ this.scheduleGalleryFocus()+ }++ protected selectGalleryImage(selectedFile: FileModel) {+ this.setCurrentFile(selectedFile)+ this.showImageView()+ }++ protected onViewerEscape(event: Event) {+ // Escape follows the navigation hierarchy: photo opened from gallery, then gallery, then modal.+ if (!this.returnToGalleryOnEscape || this.isGalleryOpen()) return++ event.preventDefault()+ event.stopPropagation()+ this.openGallery()+ }++ protected onGalleryThumbnailError(fileId: number) {+ this.galleryFailedThumbnailIds.update((failedThumbnailIds) => {+ const nextFailedThumbnailIds = new Set(failedThumbnailIds)+ nextFailedThumbnailIds.add(fileId)+ return nextFailedThumbnailIds+ })+ }++ protected onGalleryMultiTouch(event: TouchEvent) {+ if (event.touches.length > 1 && event.cancelable) event.preventDefault()+ }++ protected onImageWheel(event: WheelEvent) {+ // Trackpads emit small deltas, so accumulate them to keep zoom steps stable across devices.+ event.preventDefault()+ this.setImageZoomAnchor(event.clientX, event.clientY)+ const deltaMultiplier =+ event.deltaMode === WheelEvent.DOM_DELTA_LINE+ ? 16+ : event.deltaMode === WheelEvent.DOM_DELTA_PAGE+ ? this.canvasRef().nativeElement.clientHeight+ : 1+ const delta = event.deltaY * deltaMultiplier+ if (!delta) return++ if (this.imageWheelDelta && Math.sign(this.imageWheelDelta) !== Math.sign(delta)) this.imageWheelDelta = 0+ this.imageWheelDelta += delta+ if (Math.abs(this.imageWheelDelta) < this.imageWheelThreshold) return++ const shouldZoomIn = this.imageWheelDelta < 0+ this.imageWheelDelta = 0+ if (shouldZoomIn) {+ this.zoomIn()+ } else {+ this.zoomOut()+ }+ this.showControlsTemporarily()+ }++ protected onGesturePointerDown(event: PointerEvent) {+ if (this.isGalleryOpen()) {+ if (event.pointerType === 'touch') this.showControlsTemporarily()+ return+ }+ if (event.button !== 0) return++ const canvas = event.currentTarget as HTMLElement+ const image = this.imageRef()?.nativeElement+ if (!image) return++ if (event.pointerType === 'touch') {+ event.preventDefault()+ this.showControlsTemporarily()+ this.activeTouchPointers.set(event.pointerId, event)+ canvas.setPointerCapture?.(event.pointerId)++ if (this.activeTouchPointers.size >= 2) {+ this.startPinch()+ } else if (event.target === image && this.isImagePannable()) {+ this.startPan(event)+ } else {+ this.startSwipe(event)+ }+ return+ }++ if (!event.isPrimary || event.target !== image || !this.isImagePannable()) return++ canvas.setPointerCapture?.(event.pointerId)+ this.startPan(event)+ }++ protected onGesturePointerMove(event: PointerEvent) {+ if (this.isGalleryOpen()) return++ if (event.pointerType === 'touch' && this.activeTouchPointers.has(event.pointerId)) {+ this.activeTouchPointers.set(event.pointerId, event)++ if (this.activeTouchPointers.size >= 2) {+ event.preventDefault()+ this.updatePinch()+ this.showControlsTemporarily()+ return+ }+ }++ if (event.pointerId !== this.panPointerId) return++ event.preventDefault()+ this.setImagePosition(this.panOriginX + event.clientX - this.panStartX, this.panOriginY + event.clientY - this.panStartY)+ if (event.pointerType === 'touch') this.showControlsTemporarily()+ }++ protected onGesturePointerUp(event: PointerEvent) {+ if (this.isGalleryOpen()) return++ if (this.releaseTouchPointer(event)) return++ if (event.pointerId === this.panPointerId) {+ this.stopPan()+ } else if (event.pointerId === this.swipePointerId) {+ this.completeSwipe(event)+ }+ }++ protected onGesturePointerCancel(event: PointerEvent) {+ if (this.isGalleryOpen()) return++ if (this.releaseTouchPointer(event)) return++ if (event.pointerId === this.panPointerId) this.stopPan()+ if (event.pointerId === this.swipePointerId) this.resetSwipe()+ }++ protected onViewerPointerMove(event: PointerEvent) {+ if (event.pointerType !== 'mouse') return++ this.showControlsTemporarily()+ }++ protected onViewerPointerLeave(event: PointerEvent) {+ if (event.pointerType === 'mouse') this.scheduleControlsHide()+ }++ protected onControlsPointerEnter(event: PointerEvent) {+ if (event.pointerType !== 'mouse') return++ this.controlsHovered = true+ if (this.isViewerFullscreen()) {+ this.showControlsTemporarily()+ } else {+ this.isControlsVisible.set(true)+ this.clearControlsIdleTimer()+ }+ }++ protected onControlsPointerDown(event: PointerEvent) {+ event.stopPropagation()+ if (event.pointerType === 'touch') this.showControlsTemporarily()+ }++ protected onControlsPointerLeave(event: PointerEvent) {+ if (event.pointerType !== 'mouse') return++ this.controlsHovered = false+ this.scheduleControlsHide()+ }++ protected zoomIn(event?: MouseEvent) {+ this.updateImageZoomAnchor(event)++ const scale = this.imageScale()+ const nextScale =+ scale < this.imageZoomStepThreshold ? Math.min(scale + this.imageZoomFineStep, this.imageZoomStepThreshold) : scale + this.imageZoomCoarseStep+ this.setImageScale(Math.min(nextScale, this.imageZoomMax))+ }++ protected zoomOut(event?: MouseEvent) {+ this.updateImageZoomAnchor(event)++ const scale = this.imageScale()+ const nextScale =+ scale > this.imageZoomStepThreshold ? Math.max(scale - this.imageZoomCoarseStep, this.imageZoomStepThreshold) : scale - this.imageZoomFineStep+ this.setImageScale(Math.max(nextScale, this.imageZoomMin))+ }++ protected rotateLeft() {+ this.rotateImage(-this.imageRotationStep)+ }++ protected rotateRight() {+ this.rotateImage(this.imageRotationStep)+ }++ protected resetImageTransform() {+ this.resetImageTransformState()+ }++ protected toggleInfobox() {+ this.isInfoboxOpen.update((isOpen) => !isOpen)}protected fullscreen() {- this.imageRef().nativeElement.requestFullscreen()+ const viewer = this.viewerRef().nativeElement+ const viewerDocument = viewer.ownerDocument++ if (viewerDocument.fullscreenElement === viewer) {+ void viewerDocument.exitFullscreen()+ } else {+ void viewer.requestFullscreen().then(() => this.showControlsTemporarily())+ }+ }++ protected toggleSlideshow() {+ if (this.isSlideshowActive()) {+ this.stopSlideshow()+ } else {+ this.startSlideshow()+ }}- protected startSlideshow() {+ private startSlideshow() {+ this.clearSlideshowTimer()this.isSlideshowActive.set(true)- this.slideshowSub = timer(this.slideDelay, this.slideDelay)- .pipe(takeUntilDestroyed(this.destroyRef))- .subscribe(() => this.nextImage())+ this.slideshowTimer = setInterval(() => this.nextImage(), this.slideDelay)}- protected stopSlideshow() {- this.slideshowSub?.unsubscribe()++ private stopSlideshow() {+ this.clearSlideshowTimer()this.isSlideshowActive.set(false)}++ private clearSlideshowTimer() {+ if (this.slideshowTimer === null) return++ clearInterval(this.slideshowTimer)+ this.slideshowTimer = null+ }++ private showImageAtOffset(offset: number) {+ // Keep cyclic navigation safe if the current file disappeared from a refreshed directory.+ const images = this.directoryImages()+ if (!images.length) return++ const currentIndex = this.imageIndex()+ const nextIndex = currentIndex < 0 ? 0 : (images.length + currentIndex + offset) % images.length+ const nextFile = images[nextIndex]+ if (!nextFile || nextFile.id === this.file().id) return++ this.cancelActiveGesture()+ if (!this.isGalleryOpen()) this.startImageLoading()+ this.setCurrentFile(nextFile)+ if (this.isGalleryOpen()) this.scrollCurrentGalleryImageIntoView()+ }++ private setCurrentFile(nextFile: FileModel) {+ if (nextFile.id === this.file().id) return++ this.imageWheelDelta = 0+ this.imageResolution.set('')+ this.resetImageTransformState()+ this.file.set(nextFile)+ }++ private rotateImage(degrees: number) {+ this.imageRotation.update((rotation) => (rotation + degrees + 360) % 360)+ this.clampCurrentImagePosition()+ }++ private startPan(event: PointerEvent) {+ this.resetSwipe()+ this.panPointerId = event.pointerId+ this.panStartX = event.clientX+ this.panStartY = event.clientY+ this.panOriginX = this.imageOffsetX()+ this.panOriginY = this.imageOffsetY()+ this.isImagePanning.set(true)+ }++ private stopPan() {+ this.panPointerId = null+ this.isImagePanning.set(false)+ }++ private cancelActiveGesture() {+ const canvas = this.canvasRef().nativeElement+ const pointerIds = new Set(this.activeTouchPointers.keys())+ if (this.panPointerId !== null) pointerIds.add(this.panPointerId)+ if (this.swipePointerId !== null) pointerIds.add(this.swipePointerId)++ for (const pointerId of pointerIds) {+ if (canvas.hasPointerCapture(pointerId)) canvas.releasePointerCapture(pointerId)+ }++ this.activeTouchPointers.clear()+ this.pinchStartDistance = null+ this.stopPan()+ this.resetSwipe()+ }++ private releaseTouchPointer(event: PointerEvent) {+ if (event.pointerType !== 'touch') return false++ const wasPinching = this.pinchStartDistance !== null+ this.activeTouchPointers.delete(event.pointerId)+ if (!wasPinching) return false++ this.continueGestureAfterPinch()+ return true+ }++ private startSwipe(event: PointerEvent) {+ this.stopPan()+ this.swipePointerId = event.pointerId+ this.swipeStartX = event.clientX+ this.swipeStartY = event.clientY+ }++ private completeSwipe(event: PointerEvent) {+ if (this.swipeStartX === null || this.swipeStartY === null) return++ const deltaX = event.clientX - this.swipeStartX+ const deltaY = event.clientY - this.swipeStartY+ this.resetSwipe()++ if (Math.abs(deltaX) < this.swipeThreshold || Math.abs(deltaX) <= Math.abs(deltaY)) return++ if (deltaX < 0) {+ this.nextImage()+ } else {+ this.previousImage()+ }+ }++ private startPinch() {+ const pointers = this.activeTouchPointers.values()+ const firstPointer = pointers.next().value+ const secondPointer = pointers.next().value+ if (!firstPointer || !secondPointer) return++ const canvasRect = this.canvasRef().nativeElement.getBoundingClientRect()+ const centerX = (firstPointer.clientX + secondPointer.clientX) / 2+ const centerY = (firstPointer.clientY + secondPointer.clientY) / 2++ this.resetSwipe()+ this.stopPan()+ this.pinchCanvasCenterX = canvasRect.left + canvasRect.width / 2+ this.pinchCanvasCenterY = canvasRect.top + canvasRect.height / 2+ this.pinchStartDistance = Math.max(this.getPointerDistance(firstPointer, secondPointer), 1)+ this.pinchStartScale = this.imageScale()+ this.pinchStartOffsetX = this.imageOffsetX()+ this.pinchStartOffsetY = this.imageOffsetY()+ this.pinchStartCenterX = centerX - this.pinchCanvasCenterX+ this.pinchStartCenterY = centerY - this.pinchCanvasCenterY+ }++ private updatePinch() {+ if (this.pinchStartDistance === null) return++ const pointers = this.activeTouchPointers.values()+ const firstPointer = pointers.next().value+ const secondPointer = pointers.next().value+ if (!firstPointer || !secondPointer) return++ const distance = this.getPointerDistance(firstPointer, secondPointer)+ const scale = Math.max(this.imageZoomMin, Math.min(this.pinchStartScale * (distance / this.pinchStartDistance), this.imageZoomMax))+ const centerX = (firstPointer.clientX + secondPointer.clientX) / 2 - this.pinchCanvasCenterX+ const centerY = (firstPointer.clientY + secondPointer.clientY) / 2 - this.pinchCanvasCenterY+ const scaleRatio = scale / this.pinchStartScale++ this.imageScale.set(scale)+ this.setImagePosition(+ centerX - (this.pinchStartCenterX - this.pinchStartOffsetX) * scaleRatio,+ centerY - (this.pinchStartCenterY - this.pinchStartOffsetY) * scaleRatio+ )+ }++ private continueGestureAfterPinch() {+ if (this.activeTouchPointers.size >= 2) {+ this.startPinch()+ return+ }++ // Resume one-finger panning without turning the end of a pinch into an accidental swipe.+ this.pinchStartDistance = null+ this.clampCurrentImagePosition()+ const remainingPointer = this.activeTouchPointers.values().next().value+ if (remainingPointer && this.isImagePannable()) this.startPan(remainingPointer)+ }++ private getPointerDistance(firstPointer: PointerEvent, secondPointer: PointerEvent) {+ return Math.hypot(secondPointer.clientX - firstPointer.clientX, secondPointer.clientY - firstPointer.clientY)+ }++ private clampCurrentImagePosition() {+ this.setImagePosition(this.imageOffsetX(), this.imageOffsetY())+ }++ private setImageScale(scale: number) {+ // Preserve the image point under the pointer while changing scale.+ const previousScale = this.imageScale()+ if (scale === previousScale) return++ const canvasRect = this.canvasRef().nativeElement.getBoundingClientRect()+ const anchorX = (this.imageZoomAnchorClientX ?? canvasRect.left + canvasRect.width / 2) - canvasRect.left - canvasRect.width / 2+ const anchorY = (this.imageZoomAnchorClientY ?? canvasRect.top + canvasRect.height / 2) - canvasRect.top - canvasRect.height / 2+ const scaleRatio = scale / previousScale++ this.imageScale.set(scale)+ this.setImagePosition(anchorX - (anchorX - this.imageOffsetX()) * scaleRatio, anchorY - (anchorY - this.imageOffsetY()) * scaleRatio)+ }++ private setImageZoomAnchor(clientX: number, clientY: number) {+ this.imageZoomAnchorClientX = clientX+ this.imageZoomAnchorClientY = clientY+ }++ private updateImageZoomAnchor(event?: MouseEvent) {+ if (!event) return++ if (event.detail) {+ this.setImageZoomAnchor(event.clientX, event.clientY)+ } else {+ this.clearImageZoomAnchor()+ }+ }++ private clearImageZoomAnchor() {+ this.imageZoomAnchorClientX = null+ this.imageZoomAnchorClientY = null+ }++ private setImagePosition(x: number, y: number) {+ // Clamp translation to the transformed image bounds to avoid exposing empty canvas space.+ const canvas = this.canvasRef().nativeElement+ const image = this.imageRef()?.nativeElement+ if (!image) {+ this.isImagePannable.set(false)+ return+ }++ const scale = this.imageScale()+ const isQuarterTurn = this.imageRotation() % 180 !== 0+ const imageWidth = (isQuarterTurn ? image.offsetHeight : image.offsetWidth) * scale+ const imageHeight = (isQuarterTurn ? image.offsetWidth : image.offsetHeight) * scale+ const maxX = Math.max(0, (imageWidth - canvas.clientWidth) / 2)+ const maxY = Math.max(0, (imageHeight - canvas.clientHeight) / 2)++ this.isImagePannable.set(maxX > 0 || maxY > 0)+ this.imageOffsetX.set(Math.max(-maxX, Math.min(x, maxX)))+ this.imageOffsetY.set(Math.max(-maxY, Math.min(y, maxY)))+ }++ private resetImageTransformState() {+ this.imageScale.set(1)+ this.imageRotation.set(0)+ this.imageOffsetX.set(0)+ this.imageOffsetY.set(0)+ this.isImagePannable.set(false)+ this.isImagePanning.set(false)+ this.clearImageZoomAnchor()+ }++ private showImageView() {+ if (!this.isGalleryOpen()) return++ this.imageWheelDelta = 0+ this.startImageLoading()+ this.isGalleryOpen.set(false)+ this.showControlsTemporarily()+ this.scheduleGalleryControlFocus()+ }++ private scheduleGalleryFocus() {+ // Wait for Angular to render the gallery before moving focus and restoring its scroll position.+ this.clearGalleryRenderTimer()+ this.galleryRenderTimer = setTimeout(() => {+ this.galleryRenderTimer = null+ if (!this.isGalleryOpen()) return++ const canvas = this.canvasRef().nativeElement+ canvas.focus({ preventScroll: true })+ this.getCurrentGalleryItem()?.scrollIntoView({ block: 'center', inline: 'nearest' })+ })+ }++ private scrollCurrentGalleryImageIntoView() {+ this.getCurrentGalleryItem()?.scrollIntoView({ block: 'nearest', inline: 'nearest' })+ }++ private getCurrentGalleryItem() {+ return this.canvasRef().nativeElement.querySelector<HTMLElement>(`[data-gallery-file-id="${this.file().id}"]`)+ }++ private scheduleGalleryControlFocus() {+ // Restore keyboard focus to the gallery control after the photo view has been rendered.+ this.clearGalleryRenderTimer()+ this.galleryRenderTimer = setTimeout(() => {+ this.galleryRenderTimer = null+ if (this.isGalleryOpen()) return++ this.viewerRef().nativeElement.querySelector<HTMLElement>('.app-viewer-image-control-gallery')?.focus({ preventScroll: true })+ })+ }++ private clearGalleryRenderTimer() {+ if (this.galleryRenderTimer === null) return++ clearTimeout(this.galleryRenderTimer)+ this.galleryRenderTimer = null+ }++ private showControlsTemporarily() {+ this.isControlsVisible.set(true)+ this.scheduleControlsHide()+ }++ private startImageLoading() {+ this.clearImageLoadingTimer()+ this.imageLoadingStartedAt = Date.now()+ this.isImageLoading.set(true)+ }++ private finishImageLoading() {+ this.clearImageLoadingTimer()+ const remainingDuration = this.imageLoadingMinDuration - (Date.now() - this.imageLoadingStartedAt)++ if (remainingDuration <= 0) {+ this.isImageLoading.set(false)+ return+ }++ this.imageLoadingTimer = setTimeout(() => {+ this.isImageLoading.set(false)+ this.imageLoadingTimer = null+ }, remainingDuration)+ }++ private clearImageLoadingTimer() {+ if (this.imageLoadingTimer === null) return++ clearTimeout(this.imageLoadingTimer)+ this.imageLoadingTimer = null+ }++ private isViewerFullscreen() {+ const viewer = this.viewerRef().nativeElement+ return viewer.ownerDocument.fullscreenElement === viewer+ }++ private scheduleControlsHide() {+ // Move one deadline instead of recreating a timer on every pointer movement.+ if (this.controlsHovered && !this.isViewerFullscreen()) {+ this.clearControlsIdleTimer()+ return+ }++ this.controlsIdleDeadline = Date.now() + this.controlsIdleDelay+ this.ensureControlsIdleTimer()+ }++ private ensureControlsIdleTimer() {+ if (this.controlsIdleTimer !== null) return++ const remainingDuration = Math.max(0, this.controlsIdleDeadline - Date.now())+ this.controlsIdleTimer = setTimeout(() => this.onControlsIdleTimer(), remainingDuration)+ }++ private onControlsIdleTimer() {+ this.controlsIdleTimer = null+ if (this.controlsHovered && !this.isViewerFullscreen()) return++ const remainingDuration = this.controlsIdleDeadline - Date.now()+ if (remainingDuration > 0) {+ this.controlsIdleTimer = setTimeout(() => this.onControlsIdleTimer(), remainingDuration)+ return+ }++ this.isControlsVisible.set(false)+ }++ private clearControlsIdleTimer() {+ if (this.controlsIdleTimer === null) return++ clearTimeout(this.controlsIdleTimer)+ this.controlsIdleTimer = null+ }++ private resetSwipe() {+ this.swipePointerId = null+ this.swipeStartX = null+ this.swipeStartY = null+ }}diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.jsonindex 2160c771..4b3f8b1f 100644--- a/frontend/src/i18n/de.json+++ b/frontend/src/i18n/de.json@@ -542,6 +542,10 @@"Transfers": "Übertragungen","Simulate": "Simulieren","Reset": "Zurücksetzen",+ "Zoom out": "Verkleinern",+ "Zoom in": "Vergrößern",+ "Rotate left": "Nach links drehen",+ "Rotate right": "Nach rechts drehen","Browse": "Durchsuchen","Action": "Aktion","Added": "Hinzugefügt",@@ -764,7 +768,6 @@"Unable to update theme preference": "Die Designeinstellung konnte nicht aktualisiert werden","Unable to update editor preference": "Die Editoreinstellung konnte nicht aktualisiert werden","Unable to update sidebar preference": "Die Seitenleisteneinstellung konnte nicht aktualisiert werden",- "of": "von","Sidebar auto-hide enabled": "Automatisches Ausblenden der Seitenleiste aktiviert","Sidebar pinned": "Seitenleiste angeheftet","Continue with OpenID Connect": "Mit OpenID Connect fortfahren",diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.jsonindex cecb8fbb..c3e648ee 100644--- a/frontend/src/i18n/es.json+++ b/frontend/src/i18n/es.json@@ -542,6 +542,10 @@"Transfers": "Transferencias","Simulate": "Simular","Reset": "Restablecer",+ "Zoom out": "Alejar",+ "Zoom in": "Acercar",+ "Rotate left": "Girar a la izquierda",+ "Rotate right": "Girar a la derecha","Browse": "Examinar","Action": "Acción","Added": "Añadido",@@ -764,7 +768,6 @@"Unable to update theme preference": "No se pudo actualizar la preferencia de tema","Unable to update editor preference": "No se pudo actualizar la preferencia de editor","Unable to update sidebar preference": "No se pudo actualizar la preferencia de la barra lateral",- "of": "de","Sidebar auto-hide enabled": "Ocultación automática de la barra lateral activada","Sidebar pinned": "Barra lateral fijada","Continue with OpenID Connect": "Continuar con OpenID Connect",diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.jsonindex ae13cad0..b822cdd2 100644--- a/frontend/src/i18n/fr.json+++ b/frontend/src/i18n/fr.json@@ -542,6 +542,10 @@"Transfers": "Transferts","Simulate": "Simuler","Reset": "Réinitialiser",+ "Zoom out": "Dézoomer",+ "Zoom in": "Zoomer",+ "Rotate left": "Pivoter à gauche",+ "Rotate right": "Pivoter à droite","Browse": "Parcourir","Action": "Action","Added": "Ajouté",@@ -764,7 +768,6 @@"Unable to update theme preference": "Impossible de mettre à jour la préférence de thème","Unable to update editor preference": "Impossible de mettre à jour la préférence d’éditeur","Unable to update sidebar preference": "Impossible de mettre à jour la préférence de la barre latérale",- "of": "de","Sidebar auto-hide enabled": "Masquage automatique de la barre latérale activé","Sidebar pinned": "Barre latérale épinglée","Continue with OpenID Connect": "Continuer avec OpenID Connect",diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.jsonindex bc3be5a2..fb7eb010 100644--- a/frontend/src/i18n/hi.json+++ b/frontend/src/i18n/hi.json@@ -542,6 +542,10 @@"Transfers": "हस्तांतरण","Simulate": "अनुकरण करें","Reset": "रीसेट",+ "Zoom out": "ज़ूम आउट",+ "Zoom in": "ज़ूम इन",+ "Rotate left": "बाईं ओर घुमाएँ",+ "Rotate right": "दाईं ओर घुमाएँ","Browse": "ब्राउज़ करें","Action": "क्रिया","Added": "जोड़ा गया",@@ -764,7 +768,6 @@"Unable to update theme preference": "थीम की प्राथमिकता अपडेट नहीं की जा सकी","Unable to update editor preference": "संपादक की प्राथमिकता अपडेट नहीं की जा सकी","Unable to update sidebar preference": "साइडबार की प्राथमिकता अपडेट नहीं की जा सकी",- "of": "का","Sidebar auto-hide enabled": "साइडबार स्वतः छिपाना सक्षम","Sidebar pinned": "साइडबार पिन किया गया","Continue with OpenID Connect": "OpenID Connect के साथ जारी रखें",diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.jsonindex e230d0e8..7c0d8e98 100644--- a/frontend/src/i18n/it.json+++ b/frontend/src/i18n/it.json@@ -542,6 +542,10 @@"Transfers": "Trasferimenti","Simulate": "Simula","Reset": "Reimposta",+ "Zoom out": "Riduci",+ "Zoom in": "Ingrandisci",+ "Rotate left": "Ruota a sinistra",+ "Rotate right": "Ruota a destra","Browse": "Sfoglia","Action": "Azione","Added": "Aggiunto",@@ -764,7 +768,6 @@"Unable to update theme preference": "Impossibile aggiornare la preferenza del tema","Unable to update editor preference": "Impossibile aggiornare la preferenza dell'editor","Unable to update sidebar preference": "Impossibile aggiornare la preferenza della barra laterale",- "of": "di","Sidebar auto-hide enabled": "Nascondimento automatico della barra laterale attivato","Sidebar pinned": "Barra laterale bloccata","Continue with OpenID Connect": "Continua con OpenID Connect",diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.jsonindex 48e62ec6..b8004cd7 100644--- a/frontend/src/i18n/ja.json+++ b/frontend/src/i18n/ja.json@@ -542,6 +542,10 @@"Transfers": "転送","Simulate": "シミュレート","Reset": "リセット",+ "Zoom out": "ズームアウト",+ "Zoom in": "ズームイン",+ "Rotate left": "左に回転",+ "Rotate right": "右に回転","Browse": "参照","Action": "アクション","Added": "追加",@@ -764,7 +768,6 @@"Unable to update theme preference": "テーマ設定を更新できませんでした","Unable to update editor preference": "エディタ設定を更新できませんでした","Unable to update sidebar preference": "サイドバー設定を更新できませんでした",- "of": "の","Sidebar auto-hide enabled": "サイドバー自動非表示が有効","Sidebar pinned": "サイドバー固定","Continue with OpenID Connect": "OpenID Connectで続行",diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.jsonindex a03912cc..1269b2c7 100644--- a/frontend/src/i18n/ko.json+++ b/frontend/src/i18n/ko.json@@ -542,6 +542,10 @@"Transfers": "전송","Simulate": "시뮬레이션","Reset": "재설정",+ "Zoom out": "축소",+ "Zoom in": "확대",+ "Rotate left": "왼쪽으로 회전",+ "Rotate right": "오른쪽으로 회전","Browse": "탐색","Action": "동작","Added": "추가됨",@@ -764,7 +768,6 @@"Unable to update theme preference": "테마 설정을 업데이트할 수 없습니다","Unable to update editor preference": "편집기 설정을 업데이트할 수 없습니다","Unable to update sidebar preference": "사이드바 설정을 업데이트할 수 없습니다",- "of": "의","Sidebar auto-hide enabled": "사이드바 자동 숨김 활성화","Sidebar pinned": "사이드바 고정됨","Continue with OpenID Connect": "OpenID Connect로 계속하기",diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.jsonindex 71a2e263..6cf18504 100644--- a/frontend/src/i18n/nl.json+++ b/frontend/src/i18n/nl.json@@ -542,6 +542,10 @@"Transfers": "Overdrachten","Simulate": "Simuleren","Reset": "Herstellen",+ "Zoom out": "Uitzoomen",+ "Zoom in": "Inzoomen",+ "Rotate left": "Linksom draaien",+ "Rotate right": "Rechtsom draaien","Browse": "Bladeren","Action": "Actie","Added": "Toegevoegd",@@ -764,7 +768,6 @@"Unable to update theme preference": "Kan de themavoorkeur niet bijwerken","Unable to update editor preference": "Kan de editorvoorkeur niet bijwerken","Unable to update sidebar preference": "Kan zijbalkvoorkeur niet bijwerken",- "of": "van","Sidebar auto-hide enabled": "Zijbalk automatisch verbergen ingeschakeld","Sidebar pinned": "Zijbalk vastgemaakt","Continue with OpenID Connect": "Doorgaan met OpenID Connect",diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.jsonindex 1e73d945..a39d9ca5 100644--- a/frontend/src/i18n/pl.json+++ b/frontend/src/i18n/pl.json@@ -542,6 +542,10 @@"Transfers": "Transfery","Simulate": "Symuluj","Reset": "Resetuj",+ "Zoom out": "Pomniejsz",+ "Zoom in": "Powiększ",+ "Rotate left": "Obróć w lewo",+ "Rotate right": "Obróć w prawo","Browse": "Przeglądaj","Action": "Akcja","Added": "Dodano",@@ -764,7 +768,6 @@"Unable to update theme preference": "Nie można zaktualizować preferencji motywu","Unable to update editor preference": "Nie można zaktualizować preferencji edytora","Unable to update sidebar preference": "Nie udało się zaktualizować preferencji paska bocznego",- "of": "z","Sidebar auto-hide enabled": "Włączono automatyczne ukrywanie panelu bocznego","Sidebar pinned": "Panel boczny przypięty","Continue with OpenID Connect": "Kontynuuj z OpenID Connect",diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.jsonindex a99af258..e30647ec 100644--- a/frontend/src/i18n/pt-BR.json+++ b/frontend/src/i18n/pt-BR.json@@ -542,6 +542,10 @@"Transfers": "Transferências","Simulate": "Simular","Reset": "Redefinir",+ "Zoom out": "Diminuir zoom",+ "Zoom in": "Aumentar zoom",+ "Rotate left": "Girar para a esquerda",+ "Rotate right": "Girar para a direita","Browse": "Navegar","Action": "Ação","Added": "Adicionado",@@ -764,7 +768,6 @@"Unable to update theme preference": "Não foi possível atualizar a preferência de tema","Unable to update editor preference": "Não foi possível atualizar a preferência de editor","Unable to update sidebar preference": "Não foi possível atualizar a preferência da barra lateral",- "of": "de","Sidebar auto-hide enabled": "Ocultação automática da barra lateral ativada","Sidebar pinned": "Barra lateral fixada","Continue with OpenID Connect": "Continuar com OpenID Connect",diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.jsonindex 2fe255fd..dfc18539 100644--- a/frontend/src/i18n/pt.json+++ b/frontend/src/i18n/pt.json@@ -542,6 +542,10 @@"Transfers": "Transferências","Simulate": "Simular","Reset": "Redefinir",+ "Zoom out": "Diminuir zoom",+ "Zoom in": "Aumentar zoom",+ "Rotate left": "Rodar para a esquerda",+ "Rotate right": "Rodar para a direita","Browse": "Navegar","Action": "Ação","Added": "Adicionado",@@ -764,7 +768,6 @@"Unable to update theme preference": "Não foi possível atualizar a preferência do tema","Unable to update editor preference": "Não foi possível atualizar a preferência do editor","Unable to update sidebar preference": "Não foi possível atualizar a preferência da barra lateral",- "of": "de","Sidebar auto-hide enabled": "Ocultação automática da barra lateral ativada","Sidebar pinned": "Barra lateral fixa","Continue with OpenID Connect": "Continuar com OpenID Connect",diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.jsonindex baa969fe..fa80e513 100644--- a/frontend/src/i18n/ru.json+++ b/frontend/src/i18n/ru.json@@ -542,6 +542,10 @@"Transfers": "Передачи","Simulate": "Симулировать","Reset": "Сбросить",+ "Zoom out": "Уменьшить",+ "Zoom in": "Увеличить",+ "Rotate left": "Повернуть влево",+ "Rotate right": "Повернуть вправо","Browse": "Обзор","Action": "Действие","Added": "Добавлено",@@ -764,7 +768,6 @@"Unable to update theme preference": "Не удалось обновить настройку темы","Unable to update editor preference": "Не удалось обновить настройку редактора","Unable to update sidebar preference": "Не удалось обновить настройку боковой панели",- "of": "из","Sidebar auto-hide enabled": "Автоскрытие боковой панели включено","Sidebar pinned": "Боковая панель закреплена","Continue with OpenID Connect": "Продолжить с OpenID Connect",diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.jsonindex b315eb9b..b551d58b 100644--- a/frontend/src/i18n/tr.json+++ b/frontend/src/i18n/tr.json@@ -542,6 +542,10 @@"Transfers": "Aktarımlar","Simulate": "Simüle et","Reset": "Sıfırla",+ "Zoom out": "Uzaklaştır",+ "Zoom in": "Yakınlaştır",+ "Rotate left": "Sola döndür",+ "Rotate right": "Sağa döndür","Browse": "Gözat","Action": "İşlem","Added": "Eklendi",@@ -764,7 +768,6 @@"Unable to update theme preference": "Tema tercihi güncellenemedi","Unable to update editor preference": "Düzenleyici tercihi güncellenemedi","Unable to update sidebar preference": "Kenar çubuğu tercihi güncellenemedi",- "of": "/","Sidebar auto-hide enabled": "Kenar çubuğu otomatik gizleme etkin","Sidebar pinned": "Kenar çubuğu sabitlendi","Continue with OpenID Connect": "OpenID Connect ile devam et",diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.jsonindex 72a19670..2fa29550 100644--- a/frontend/src/i18n/zh.json+++ b/frontend/src/i18n/zh.json@@ -542,6 +542,10 @@"Transfers": "传输","Simulate": "模拟","Reset": "重置",+ "Zoom out": "缩小",+ "Zoom in": "放大",+ "Rotate left": "向左旋转",+ "Rotate right": "向右旋转","Browse": "浏览","Action": "操作","Added": "已添加",@@ -764,7 +768,6 @@"Unable to update theme preference": "无法更新主题偏好设置","Unable to update editor preference": "无法更新编辑器偏好设置","Unable to update sidebar preference": "无法更新侧边栏偏好设置",- "of": "的","Sidebar auto-hide enabled": "侧边栏自动隐藏已启用","Sidebar pinned": "侧边栏已固定","Continue with OpenID Connect": "使用 OpenID Connect 继续",diff --git a/frontend/src/styles/components/_app.scss b/frontend/src/styles/components/_app.scssindex 89e294ee..ee25b432 100755--- a/frontend/src/styles/components/_app.scss+++ b/frontend/src/styles/components/_app.scss@@ -518,24 +518,6 @@ app-input-filter {border: none;}-.app-viewer-image {- display: flex;- justify-content: center;- background-color: lighten($sidebar-dark-apps-menu-title-bg, 4%);-- img {- @extend .img-fluid;- align-self: center;- }-- .info-box {- position: absolute;- bottom: 0;- right: 0;- width: $control-sidebar-width;- }-}-.app-comment {textarea {padding: .15rem .3rem;diff --git a/frontend/src/styles/components/_modal.scss b/frontend/src/styles/components/_modal.scssindex 991a5cdd..1485c119 100644--- a/frontend/src/styles/components/_modal.scss+++ b/frontend/src/styles/components/_modal.scss@@ -1,4 +1,6 @@.modal {+ --modal-header-height: #{$modal-header-height};+// backdropbackground: rgba(0, 0, 0, .6);@@ -7,8 +9,8 @@}.modal-header {- max-height: 41.5px;- height: 41.5px;+ max-height: $modal-header-height;+ height: $modal-header-height;line-height: 1;@include no-select-utility;diff --git a/frontend/src/styles/variables.scss b/frontend/src/styles/variables.scssindex e0521e79..b2bc71ab 100644--- a/frontend/src/styles/variables.scss+++ b/frontend/src/styles/variables.scss@@ -181,6 +181,7 @@ $dropdown-header-color: #8aa4af;// --------------------------------------------------------$modal-inner-padding: .4rem;+$modal-header-height: 41.5px;$modal-header-padding-x: .8rem;$modal-header-padding-y: .5rem;$modal-xs: 300px;