Skip to content

Commit 08bd9d6

Browse files
committed
tweak
1 parent 605a1f7 commit 08bd9d6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/svelte/src/index-client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ export function afterUpdate(fn) {
208208
* @returns {void}
209209
*/
210210
export function onAnimationFrame(fn) {
211-
onMount(() => {
212-
let frame = -1;
211+
if (component_context === null) {
212+
lifecycle_outside_component('onAnimationFrame');
213+
}
213214

214-
function next() {
215+
user_effect(() => {
216+
let frame = requestAnimationFrame(function next() {
215217
frame = requestAnimationFrame(next);
216218
fn();
217-
}
218-
219-
next();
219+
});
220220

221221
return () => {
222222
cancelAnimationFrame(frame);

0 commit comments

Comments
 (0)