mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 01:11:47 +03:00
fix: flash bug on tag (#12332)
* fix flash bug on tag * fix lint --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -10,10 +10,10 @@ type TrackedProperties = {
|
||||
left?: string;
|
||||
};
|
||||
type OnIntersectCallback = (entryOrElement: IntersectionObserverEntry | HTMLElement) => unknown;
|
||||
type OnSeperateCallback = (element: HTMLElement) => unknown;
|
||||
type OnSeparateCallback = (element: HTMLElement) => unknown;
|
||||
type IntersectionObserverActionProperties = {
|
||||
key?: string;
|
||||
onSeparate?: OnSeperateCallback;
|
||||
onSeparate?: OnSeparateCallback;
|
||||
onIntersect?: OnIntersectCallback;
|
||||
|
||||
root?: Element | Document | null;
|
||||
@@ -22,8 +22,6 @@ type IntersectionObserverActionProperties = {
|
||||
right?: string;
|
||||
bottom?: string;
|
||||
left?: string;
|
||||
|
||||
disabled?: boolean;
|
||||
};
|
||||
type TaskKey = HTMLElement | string;
|
||||
|
||||
@@ -92,11 +90,7 @@ function _intersectionObserver(
|
||||
element: HTMLElement,
|
||||
properties: IntersectionObserverActionProperties,
|
||||
) {
|
||||
if (properties.disabled) {
|
||||
properties.onIntersect?.(element);
|
||||
} else {
|
||||
configure(key, element, properties);
|
||||
}
|
||||
configure(key, element, properties);
|
||||
return {
|
||||
update(properties: IntersectionObserverActionProperties) {
|
||||
const config = elementToConfig.get(key);
|
||||
@@ -106,20 +100,14 @@ function _intersectionObserver(
|
||||
if (isEquivalent(config, properties)) {
|
||||
return;
|
||||
}
|
||||
|
||||
configure(key, element, properties);
|
||||
},
|
||||
destroy: () => {
|
||||
if (properties.disabled) {
|
||||
properties.onSeparate?.(element);
|
||||
} else {
|
||||
const config = elementToConfig.get(key);
|
||||
const { observer, onSeparate } = config || {};
|
||||
observer?.unobserve(element);
|
||||
elementToConfig.delete(key);
|
||||
if (onSeparate) {
|
||||
onSeparate?.(element);
|
||||
}
|
||||
}
|
||||
const config = elementToConfig.get(key);
|
||||
const { observer } = config || {};
|
||||
observer?.unobserve(element);
|
||||
elementToConfig.delete(key);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -148,5 +136,5 @@ export function intersectionObserver(
|
||||
},
|
||||
};
|
||||
}
|
||||
return _intersectionObserver(element, element, properties);
|
||||
return _intersectionObserver(properties.key || element, element, properties);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user