[Perf] useSharedIntersectionObserver: Consider heavy animation (follow-up)

This commit is contained in:
Alexander Zinchuk 2024-09-19 20:43:51 +02:00
parent be4c220228
commit e56461a43c

View File

@ -2,6 +2,7 @@ import { getIsHeavyAnimating, useEffect } from '../lib/teact/teact';
import type { CallbackManager } from '../util/callbacks';
import { requestMeasure } from '../lib/fasterdom/fasterdom';
import { createCallbackManager } from '../util/callbacks';
import useLastCallback from './useLastCallback';
@ -41,7 +42,9 @@ export default function useSharedIntersectionObserver(
if (!getIsHeavyAnimating()) {
flush();
} else {
getIsHeavyAnimating.once(flush);
getIsHeavyAnimating.once(() => {
requestMeasure(flush);
});
}
};