File "after-animations.js"

Full Path: /home/exogold/public_html/wp-content/plugins/extendify/src/QuickEdit/lib/after-animations.js
File size: 485 bytes
MIME-type: text/plain
Charset: utf-8

// A block entering on scroll measures where the animation starts.
export const whenAnimationsSettle = (el, onSettled) => {
	const running = el?.getAnimations?.({ subtree: true }) ?? [];
	if (!running.length) return () => {};
	let dropped = false;
	Promise.all(running.map((animation) => animation.finished))
		.then(() => !dropped && onSettled())
		// A cancelled animation rejects, and means nothing landed to re-measure.
		.catch(() => {});
	return () => {
		dropped = true;
	};
};