feat: handle escape key and higher wheel zoom ratio (#3471)

This commit is contained in:
martin 2023-07-30 18:03:08 +02:00 committed by GitHub
parent 95c75c289c
commit e368b9e50b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 12 deletions

View file

@ -13,7 +13,7 @@
UserResponseDto,
api,
} from '@api';
import { onMount } from 'svelte';
import { onDestroy, onMount } from 'svelte';
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
import DeleteOutline from 'svelte-material-icons/DeleteOutline.svelte';
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
@ -43,6 +43,7 @@
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
import { handleError } from '../../utils/handle-error';
import { downloadArchive } from '../../utils/asset-utils';
import { isViewingAssetStoreState } from '$lib/stores/asset-interaction.store';
export let album: AlbumResponseDto;
export let sharedLink: SharedLinkResponseDto | undefined = undefined;
@ -119,7 +120,10 @@
return startDateString === endDateString ? startDateString : `${startDateString} - ${endDateString}`;
};
const onKeyboardPress = (event: KeyboardEvent) => handleKeyboardPress(event);
onMount(async () => {
document.addEventListener('keydown', onKeyboardPress);
currentAlbumName = album.albumName;
try {
@ -130,6 +134,26 @@
}
});
onDestroy(() => {
if (browser) {
document.removeEventListener('keydown', onKeyboardPress);
}
});
const handleKeyboardPress = (event: KeyboardEvent) => {
if (!$isViewingAssetStoreState) {
switch (event.key) {
case 'Escape':
if (isMultiSelectionMode) {
multiSelectAsset = new Set();
} else {
goto(backUrl);
}
return;
}
}
};
// Update Album Name
$: {
if (!isEditingTitle && currentAlbumName != album.albumName && isOwned) {