1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-24 05:17:16 +02:00

Improving Directory UI responsiveness #587

This commit is contained in:
Patrik J. Braun 2023-03-07 00:24:26 +01:00
parent 335033dde8
commit a31ddf75be
8 changed files with 58 additions and 24 deletions

View File

@ -431,13 +431,22 @@ export class NavBarConfig {
]; ];
@ConfigProperty({ @ConfigProperty({
tags: { tags: {
name: $localize`Navbar show/hide delay`, name: $localize`Navbar show delay`,
priority: ConfigPriority.underTheHood priority: ConfigPriority.underTheHood
}, },
type: 'ratio', type: 'positiveFloat',
description: $localize`Ratio of the page height, you need to scroll to show or hide the navigationbar.`, description: $localize`Ratio of the page height, you need to scroll to show the navigation bar.`,
}) })
NavbarShowHideDelay: number = 0.15; NavbarShowDelay: number = 0.30;
@ConfigProperty({
tags: {
name: $localize`Navbar hide delay`,
priority: ConfigPriority.underTheHood
},
type: 'positiveFloat',
description: $localize`Ratio of the page height, you need to scroll to hide the navigation bar.`,
})
NavbarHideDelay: number = 0.15;
} }
@SubConfigClass<TAGS>({tags: {client: true}, softReadonly: true}) @SubConfigClass<TAGS>({tags: {client: true}, softReadonly: true})

View File

@ -99,11 +99,11 @@ import {FilterService} from './ui/gallery/filter/filter.service';
import {TemplateComponent} from './ui/settings/template/template.component'; import {TemplateComponent} from './ui/settings/template/template.component';
import {WorkflowComponent} from './ui/settings/workflow/workflow.component'; import {WorkflowComponent} from './ui/settings/workflow/workflow.component';
import {GalleryStatisticComponent} from './ui/settings/gallery-statistic/gallery-statistic.component'; import {GalleryStatisticComponent} from './ui/settings/gallery-statistic/gallery-statistic.component';
import { JobButtonComponent } from './ui/settings/workflow/button/job-button.settings.component'; import {JobButtonComponent} from './ui/settings/workflow/button/job-button.settings.component';
import { JobProgressComponent } from './ui/settings/workflow/progress/job-progress.settings.component'; import {JobProgressComponent} from './ui/settings/workflow/progress/job-progress.settings.component';
import {SettingsEntryComponent} from './ui/settings/template/settings-entry/settings-entry.component'; import {SettingsEntryComponent} from './ui/settings/template/settings-entry/settings-entry.component';
import { UsersComponent } from './ui/settings/users/users.component'; import {UsersComponent} from './ui/settings/users/users.component';
import { SharingsListComponent } from './ui/settings/sharings-list/sharings-list.component'; import {SharingsListComponent} from './ui/settings/sharings-list/sharings-list.component';
@Injectable() @Injectable()
export class MyHammerConfig extends HammerGestureConfig { export class MyHammerConfig extends HammerGestureConfig {
@ -272,7 +272,9 @@ Marker.prototype.options.icon = iconDefault;
VersionService, VersionService,
ScheduledJobsService, ScheduledJobsService,
BackendtextService, BackendtextService,
CookieService CookieService,
GPXFilesFilterPipe,
MDFilesFilterPipe,
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })

View File

@ -97,8 +97,8 @@ export class FrameComponent {
const scrollPosition = PageHelper.ScrollY; const scrollPosition = PageHelper.ScrollY;
const up = this.lastScroll.any > scrollPosition; const up = this.lastScroll.any > scrollPosition;
const down = this.lastScroll.any < scrollPosition; const down = this.lastScroll.any < scrollPosition;
const upDelay = up && this.lastScroll.down > scrollPosition + window.innerHeight * Config.Gallery.NavBar.NavbarShowHideDelay; const upDelay = up && this.lastScroll.down > scrollPosition + window.innerHeight * Config.Gallery.NavBar.NavbarShowDelay;
const downDelay = down && this.lastScroll.up < scrollPosition - window.innerHeight * Config.Gallery.NavBar.NavbarShowHideDelay; const downDelay = down && this.lastScroll.up < scrollPosition - window.innerHeight * Config.Gallery.NavBar.NavbarHideDelay;
//we are the top where the navbar by default lives //we are the top where the navbar by default lives
if (this.navContainer.nativeElement.offsetHeight > scrollPosition) { if (this.navContainer.nativeElement.offsetHeight > scrollPosition) {

View File

@ -1,6 +1,6 @@
import { Component, ElementRef, Input, OnChanges } from '@angular/core'; import {Component, ElementRef, HostListener, Input, OnChanges} from '@angular/core';
import { DeviceDetectorService } from 'ngx-device-detector'; import {DeviceDetectorService} from 'ngx-device-detector';
import { SubDirectoryDTO } from '../../../../../common/entities/DirectoryDTO'; import {SubDirectoryDTO} from '../../../../../common/entities/DirectoryDTO';
@Component({ @Component({
selector: 'app-gallery-directories', selector: 'app-gallery-directories',
@ -23,15 +23,25 @@ export class DirectoriesComponent implements OnChanges {
this.updateSize(); this.updateSize();
} }
@HostListener('window:resize')
onResize(): void {
this.updateSize();
}
private updateSize(): void { private updateSize(): void {
if (!this.container?.nativeElement?.clientWidth) {
return;
}
const directoryMargin = 2; // 2px margin on both sides
const containerWidth =
this.container.nativeElement.clientWidth - 1; // the browser sometimes makes some rounding error. Sacrifice 1px to make that error up.
if (!this.isDesktop && window.innerWidth < window.innerHeight) { if (!this.isDesktop && window.innerWidth < window.innerHeight) {
// On portrait mode, show 2 directories side by side with some padding // On portrait mode, show 2 directories side by side with some padding
this.size = Math.round(window.innerWidth / 2) - 25; this.size = Math.floor(containerWidth / 2 - (directoryMargin * 2));
} else { } else {
const size = 220 + 5; const targetSize = 220 + directoryMargin;
const containerWidth = this.size = Math.floor(containerWidth / Math.round((containerWidth / targetSize)) - directoryMargin * 2);
this.container.nativeElement.parentElement.clientWidth;
this.size = containerWidth / Math.round(containerWidth / size) - 5;
} }
} }
} }

View File

@ -55,6 +55,7 @@ app-gallery-map {
.directories { .directories {
margin-right: 2px; margin-right: 2px;
margin-left: 2px; margin-left: 2px;
display: block;
} }

View File

@ -39,10 +39,10 @@
<app-gallery-directories class="directories" <app-gallery-directories class="directories"
[directories]="directoryContent?.directories || []"></app-gallery-directories> [directories]="directoryContent?.directories || []"></app-gallery-directories>
<div class="blog-map-row"> <div class="blog-map-row" *ngIf="ShowMarkDown || ShowMap">
<div class="blog-wrapper" <div class="blog-wrapper"
[style.width]="blogOpen ? '100%' : 'calc(100% - 100px)'" [style.width]="blogOpen ? '100%' : 'calc(100% - 100px)'"
*ngIf="config.MetaFile.markdown && directoryContent?.metaFile && (directoryContent.metaFile | mdFiles).length>0"> *ngIf="ShowMarkDown">
<app-gallery-blog [collapsed]="!blogOpen" <app-gallery-blog [collapsed]="!blogOpen"
[mdFiles]="directoryContent.metaFile | mdFiles"></app-gallery-blog> [mdFiles]="directoryContent.metaFile | mdFiles"></app-gallery-blog>
@ -52,7 +52,7 @@
</button> </button>
</div> </div>
<app-gallery-map <app-gallery-map
*ngIf="(isPhotoWithLocation || (directoryContent?.metaFile | gpxFiles)?.length > 0) && mapEnabled" *ngIf="ShowMap"
[photos]="directoryContent?.media | photosOnly" [photos]="directoryContent?.media | photosOnly"
[gpxFiles]="directoryContent?.metaFile | gpxFiles"></app-gallery-map> [gpxFiles]="directoryContent?.metaFile | gpxFiles"></app-gallery-map>
</div> </div>

View File

@ -16,6 +16,8 @@ import {GallerySortingService} from './navigator/sorting.service';
import {MediaDTO} from '../../../../common/entities/MediaDTO'; import {MediaDTO} from '../../../../common/entities/MediaDTO';
import {FilterService} from './filter/filter.service'; import {FilterService} from './filter/filter.service';
import {PiTitleService} from '../../model/pi-title.service'; import {PiTitleService} from '../../model/pi-title.service';
import {GPXFilesFilterPipe} from '../../pipes/GPXFilesFilterPipe';
import {MDFilesFilterPipe} from '../../pipes/MDFilesFilterPipe';
@Component({ @Component({
selector: 'app-gallery', selector: 'app-gallery',
@ -59,7 +61,9 @@ export class GalleryComponent implements OnInit, OnDestroy {
private navigation: NavigationService, private navigation: NavigationService,
private filterService: FilterService, private filterService: FilterService,
private sortingService: GallerySortingService, private sortingService: GallerySortingService,
private piTitleService: PiTitleService private piTitleService: PiTitleService,
private gpxFilesFilterPipe: GPXFilesFilterPipe,
private mdFilesFilterPipe:MDFilesFilterPipe,
) { ) {
this.mapEnabled = Config.Map.enabled; this.mapEnabled = Config.Map.enabled;
PageHelper.showScrollY(); PageHelper.showScrollY();
@ -199,4 +203,12 @@ export class GalleryComponent implements OnInit, OnDestroy {
} }
} }
}; };
get ShowMarkDown():boolean{
return this.config.MetaFile.markdown && this.directoryContent?.metaFile && this.mdFilesFilterPipe.transform(this.directoryContent.metaFile).length>0;
}
get ShowMap():boolean{
return (this.isPhotoWithLocation || this.gpxFilesFilterPipe.transform(this.directoryContent?.metaFile)?.length > 0) && this.mapEnabled;
}
} }

View File

@ -199,7 +199,7 @@ export class GalleryNavigatorComponent {
const scrollPosition = PageHelper.ScrollY; const scrollPosition = PageHelper.ScrollY;
if (this.lastScroll.any < scrollPosition) { // scroll down if (this.lastScroll.any < scrollPosition) { // scroll down
//hide delay //hide delay
if (this.lastScroll.up < scrollPosition - window.innerHeight * Config.Gallery.NavBar.NavbarShowHideDelay) { if (this.lastScroll.up < scrollPosition - window.innerHeight * Config.Gallery.NavBar.NavbarHideDelay) {
this.showFilters = false; this.showFilters = false;
this.dropdown.hide(); this.dropdown.hide();
} }