mirror of
https://github.com/immich-app/immich.git
synced 2025-10-16 19:40:36 -04:00
Rename scroll compensation functions for clarity
• Rename handleScrollCompensation to scrollCompensation • Rename scrollTop prop to onScrollToTop to match event handler pattern • Add onScrollCompensation alias for consistency with other event handlers
This commit is contained in:
parent
9a30198238
commit
cfdc93e4aa
@ -33,12 +33,8 @@
|
|||||||
assetInteraction: AssetInteraction;
|
assetInteraction: AssetInteraction;
|
||||||
customLayout?: Snippet<[TimelineAsset]>;
|
customLayout?: Snippet<[TimelineAsset]>;
|
||||||
onSelect: (asset: TimelineAsset) => void;
|
onSelect: (asset: TimelineAsset) => void;
|
||||||
|
|
||||||
// onSelect: ({ title, assets }: { title: string; assets: TimelineAsset[] }) => void;
|
|
||||||
// onSelectAssets: (asset: TimelineAsset) => void;
|
|
||||||
// onSelectAssetCandidates: (asset: TimelineAsset | null) => void;
|
|
||||||
onScrollCompensation: (compensation: { heightDelta?: number; scrollTop?: number }) => void;
|
onScrollCompensation: (compensation: { heightDelta?: number; scrollTop?: number }) => void;
|
||||||
scrollTop: (top: number) => void;
|
onScrollToTop: () => void;
|
||||||
onThumbnailClick?: (
|
onThumbnailClick?: (
|
||||||
asset: TimelineAsset,
|
asset: TimelineAsset,
|
||||||
timelineManager: TimelineManager,
|
timelineManager: TimelineManager,
|
||||||
@ -63,7 +59,7 @@
|
|||||||
customLayout,
|
customLayout,
|
||||||
onSelect,
|
onSelect,
|
||||||
onScrollCompensation,
|
onScrollCompensation,
|
||||||
scrollTop,
|
onScrollToTop,
|
||||||
onThumbnailClick,
|
onThumbnailClick,
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
@ -74,7 +70,7 @@
|
|||||||
actionLib.timelineManager = timelineManager;
|
actionLib.timelineManager = timelineManager;
|
||||||
actionLib.singleSelect = singleSelect;
|
actionLib.singleSelect = singleSelect;
|
||||||
actionLib.onSelect = onSelect;
|
actionLib.onSelect = onSelect;
|
||||||
actionLib.scrollTop = scrollTop;
|
actionLib.onScrollToTop = onScrollToTop;
|
||||||
});
|
});
|
||||||
|
|
||||||
let isMouseOverGroup = $state(false);
|
let isMouseOverGroup = $state(false);
|
||||||
|
@ -132,6 +132,7 @@
|
|||||||
const scrollToTop = () => {
|
const scrollToTop = () => {
|
||||||
scrollTo(0);
|
scrollTo(0);
|
||||||
};
|
};
|
||||||
|
const onScrollToTop = scrollToTop;
|
||||||
|
|
||||||
const getAssetHeight = (assetId: string, monthGroup: MonthGroup) => {
|
const getAssetHeight = (assetId: string, monthGroup: MonthGroup) => {
|
||||||
// the following method may trigger any layouts, so need to
|
// the following method may trigger any layouts, so need to
|
||||||
@ -139,7 +140,7 @@
|
|||||||
const height = monthGroup!.findAssetAbsolutePosition(assetId);
|
const height = monthGroup!.findAssetAbsolutePosition(assetId);
|
||||||
|
|
||||||
while (timelineManager.scrollCompensation.monthGroup) {
|
while (timelineManager.scrollCompensation.monthGroup) {
|
||||||
handleScrollCompensation(timelineManager.scrollCompensation);
|
scrollCompensation(timelineManager.scrollCompensation);
|
||||||
timelineManager.clearScrollCompensation();
|
timelineManager.clearScrollCompensation();
|
||||||
}
|
}
|
||||||
return height;
|
return height;
|
||||||
@ -247,7 +248,7 @@
|
|||||||
// note: don't throttle, debounch, or otherwise do this function async - it causes flicker
|
// note: don't throttle, debounch, or otherwise do this function async - it causes flicker
|
||||||
const updateSlidingWindow = () => timelineManager.updateSlidingWindow(element?.scrollTop || 0);
|
const updateSlidingWindow = () => timelineManager.updateSlidingWindow(element?.scrollTop || 0);
|
||||||
|
|
||||||
const handleScrollCompensation = ({ heightDelta, scrollTop }: { heightDelta?: number; scrollTop?: number }) => {
|
const scrollCompensation = ({ heightDelta, scrollTop }: { heightDelta?: number; scrollTop?: number }) => {
|
||||||
if (heightDelta !== undefined) {
|
if (heightDelta !== undefined) {
|
||||||
scrollBy(heightDelta);
|
scrollBy(heightDelta);
|
||||||
} else if (scrollTop !== undefined) {
|
} else if (scrollTop !== undefined) {
|
||||||
@ -259,6 +260,7 @@
|
|||||||
// causing bad perf, and also, disrupting focus of those elements.
|
// causing bad perf, and also, disrupting focus of those elements.
|
||||||
updateSlidingWindow();
|
updateSlidingWindow();
|
||||||
};
|
};
|
||||||
|
const onScrollCompensation = scrollCompensation;
|
||||||
|
|
||||||
const topSectionResizeObserver: OnResizeCallback = ({ height }) => (timelineManager.topSectionHeight = height);
|
const topSectionResizeObserver: OnResizeCallback = ({ height }) => (timelineManager.topSectionHeight = height);
|
||||||
|
|
||||||
@ -346,8 +348,8 @@
|
|||||||
{singleSelect}
|
{singleSelect}
|
||||||
{monthGroup}
|
{monthGroup}
|
||||||
{onSelect}
|
{onSelect}
|
||||||
{scrollTop}
|
{onScrollToTop}
|
||||||
onScrollCompensation={handleScrollCompensation}
|
{onScrollCompensation}
|
||||||
{customLayout}
|
{customLayout}
|
||||||
{onThumbnailClick}
|
{onThumbnailClick}
|
||||||
/>
|
/>
|
||||||
|
@ -10,7 +10,7 @@ import { searchStore } from '$lib/stores/search.svelte';
|
|||||||
*/
|
*/
|
||||||
export class DateGroupActionLib {
|
export class DateGroupActionLib {
|
||||||
onSelect: (asset: TimelineAsset) => void = () => void 0;
|
onSelect: (asset: TimelineAsset) => void = () => void 0;
|
||||||
scrollTop: (top: number) => void = () => void 0;
|
onScrollToTop: () => void = () => void 0;
|
||||||
assetInteraction: AssetInteraction = $state(new AssetInteraction());
|
assetInteraction: AssetInteraction = $state(new AssetInteraction());
|
||||||
timelineManager: TimelineManager = $state(new TimelineManager());
|
timelineManager: TimelineManager = $state(new TimelineManager());
|
||||||
singleSelect: boolean = $state(false);
|
singleSelect: boolean = $state(false);
|
||||||
@ -94,7 +94,7 @@ export class DateGroupActionLib {
|
|||||||
this.onSelect(asset);
|
this.onSelect(asset);
|
||||||
|
|
||||||
if (this.singleSelect) {
|
if (this.singleSelect) {
|
||||||
this.scrollTop(0);
|
this.onScrollToTop();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user