mirror of
https://github.com/immich-app/immich.git
synced 2025-09-09 18:27:03 -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
e3209a48e6
commit
7a947e7905
@ -29,12 +29,8 @@
|
||||
timelineManager: TimelineManager;
|
||||
assetInteraction: AssetInteraction;
|
||||
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;
|
||||
scrollTop: (top: number) => void;
|
||||
onScrollToTop: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
@ -47,7 +43,7 @@
|
||||
timelineManager,
|
||||
onSelect,
|
||||
onScrollCompensation,
|
||||
scrollTop,
|
||||
onScrollToTop,
|
||||
}: Props = $props();
|
||||
|
||||
const actionLib = new DateGroupActionLib();
|
||||
@ -57,7 +53,7 @@
|
||||
actionLib.timelineManager = timelineManager;
|
||||
actionLib.singleSelect = singleSelect;
|
||||
actionLib.onSelect = onSelect;
|
||||
actionLib.scrollTop = scrollTop;
|
||||
actionLib.onScrollToTop = onScrollToTop;
|
||||
});
|
||||
|
||||
let isMouseOverGroup = $state(false);
|
||||
|
@ -117,6 +117,7 @@
|
||||
const scrollToTop = () => {
|
||||
scrollTo(0);
|
||||
};
|
||||
const onScrollToTop = scrollToTop;
|
||||
|
||||
const getAssetHeight = (assetId: string, monthGroup: MonthGroup) => {
|
||||
// the following method may trigger any layouts, so need to
|
||||
@ -124,7 +125,7 @@
|
||||
const height = monthGroup!.findAssetAbsolutePosition(assetId);
|
||||
|
||||
while (timelineManager.scrollCompensation.monthGroup) {
|
||||
handleScrollCompensation(timelineManager.scrollCompensation);
|
||||
scrollCompensation(timelineManager.scrollCompensation);
|
||||
timelineManager.clearScrollCompensation();
|
||||
}
|
||||
return height;
|
||||
@ -232,7 +233,7 @@
|
||||
// note: don't throttle, debounch, or otherwise do this function async - it causes flicker
|
||||
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) {
|
||||
scrollBy(heightDelta);
|
||||
} else if (scrollTop !== undefined) {
|
||||
@ -244,6 +245,7 @@
|
||||
// causing bad perf, and also, disrupting focus of those elements.
|
||||
updateSlidingWindow();
|
||||
};
|
||||
const onScrollCompensation = scrollCompensation;
|
||||
|
||||
const topSectionResizeObserver: OnResizeCallback = ({ height }) => (timelineManager.topSectionHeight = height);
|
||||
|
||||
@ -331,8 +333,8 @@
|
||||
{singleSelect}
|
||||
{monthGroup}
|
||||
{onSelect}
|
||||
{scrollTop}
|
||||
onScrollCompensation={handleScrollCompensation}
|
||||
{onScrollToTop}
|
||||
{onScrollCompensation}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
|
@ -10,7 +10,7 @@ import { searchStore } from '$lib/stores/search.svelte';
|
||||
*/
|
||||
export class DateGroupActionLib {
|
||||
onSelect: (asset: TimelineAsset) => void = () => void 0;
|
||||
scrollTop: (top: number) => void = () => void 0;
|
||||
onScrollToTop: () => void = () => void 0;
|
||||
assetInteraction: AssetInteraction = $state(new AssetInteraction());
|
||||
timelineManager: TimelineManager = $state(new TimelineManager());
|
||||
singleSelect: boolean = $state(false);
|
||||
@ -94,7 +94,7 @@ export class DateGroupActionLib {
|
||||
this.onSelect(asset);
|
||||
|
||||
if (this.singleSelect) {
|
||||
this.scrollTop(0);
|
||||
this.onScrollToTop();
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user