onframe
Rich Harris 7 months ago
parent 605a1f732c
commit 08bd9d644a

@ -208,15 +208,15 @@ export function afterUpdate(fn) {
* @returns {void} * @returns {void}
*/ */
export function onAnimationFrame(fn) { export function onAnimationFrame(fn) {
onMount(() => { if (component_context === null) {
let frame = -1; lifecycle_outside_component('onAnimationFrame');
}
function next() { user_effect(() => {
let frame = requestAnimationFrame(function next() {
frame = requestAnimationFrame(next); frame = requestAnimationFrame(next);
fn(); fn();
} });
next();
return () => { return () => {
cancelAnimationFrame(frame); cancelAnimationFrame(frame);

Loading…
Cancel
Save