From 917c70f0d36261a423d4e099c6f5040c44559255 Mon Sep 17 00:00:00 2001 From: Antonio Stoilkov Date: Wed, 23 Aug 2023 12:31:00 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20better=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/afterFrame.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/afterFrame.ts b/src/afterFrame.ts index 32f8581..0dfee9e 100644 --- a/src/afterFrame.ts +++ b/src/afterFrame.ts @@ -1,6 +1,11 @@ import queueTask from './queueTask' -// inspired by: https://github.com/andrewiggins/afterframe +/** + * Calls the callback after the browser renders the next frame. + * Compared to requestAnimationFrame() that calls the callback before the next frame. + * Inspired by: https://github.com/andrewiggins/afterframe + * @param callback + */ export default function afterFrame(callback: () => void): void { requestAnimationFrame(() => { queueTask(callback)