pull/2856/head
Richard Harris 5 years ago
parent a5fe09c481
commit 9d53f568fa

@ -86,9 +86,13 @@ export let now = is_client
? () => window.performance.now()
: () => Date.now();
export let raf = is_client ? requestAnimationFrame : noop;
// used internally for testing
export function set_now(fn) {
now = fn;
}
export const raf = is_client ? requestAnimationFrame : noop;
export function set_raf(fn) {
raf = fn;
}

@ -53,4 +53,4 @@ class Component extends SvelteComponentDev {
}
}
export default Component;
export default Component;

@ -8,6 +8,7 @@ import {
insert,
listen,
noop,
raf,
run_all,
safe_not_equal,
time_ranges_to_array
@ -18,7 +19,7 @@ function create_fragment(ctx) {
function audio_timeupdate_handler() {
cancelAnimationFrame(audio_animationframe);
if (!audio.paused) audio_animationframe = requestAnimationFrame(audio_timeupdate_handler);
if (!audio.paused) audio_animationframe = raf(audio_timeupdate_handler);
audio_updating = true;
ctx.audio_timeupdate_handler.call(audio);
}

@ -3,7 +3,7 @@ import * as path from "path";
import * as fs from "fs";
import { rollup } from 'rollup';
import * as virtual from 'rollup-plugin-virtual';
import { clear_loops, set_now } from "../../internal.js";
import { clear_loops, set_now, set_raf } from "../../internal.js";
import {
showOutput,
@ -101,7 +101,7 @@ describe("runtime", () => {
}
};
set_now(() => raf.time);
global.requestAnimationFrame = cb => {
set_raf(cb => {
let called = false;
raf.callback = () => {
if (!called) {
@ -109,7 +109,7 @@ describe("runtime", () => {
cb();
}
};
};
});
try {
mod = require(`./samples/${dir}/main.svelte`);

Loading…
Cancel
Save