File tree 4 files changed +11
-6
lines changed
4 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -86,9 +86,13 @@ export let now = is_client
86
86
? ( ) => window . performance . now ( )
87
87
: ( ) => Date . now ( ) ;
88
88
89
+ export let raf = is_client ? requestAnimationFrame : noop ;
90
+
89
91
// used internally for testing
90
92
export function set_now ( fn ) {
91
93
now = fn ;
92
94
}
93
95
94
- export const raf = is_client ? requestAnimationFrame : noop ;
96
+ export function set_raf ( fn ) {
97
+ raf = fn ;
98
+ }
Original file line number Diff line number Diff line change @@ -53,4 +53,4 @@ class Component extends SvelteComponentDev {
53
53
}
54
54
}
55
55
56
- export default Component ;
56
+ export default Component ;
Original file line number Diff line number Diff line change 8
8
insert ,
9
9
listen ,
10
10
noop ,
11
+ raf ,
11
12
run_all ,
12
13
safe_not_equal ,
13
14
time_ranges_to_array
@@ -18,7 +19,7 @@ function create_fragment(ctx) {
18
19
19
20
function audio_timeupdate_handler ( ) {
20
21
cancelAnimationFrame ( audio_animationframe ) ;
21
- if ( ! audio . paused ) audio_animationframe = requestAnimationFrame ( audio_timeupdate_handler ) ;
22
+ if ( ! audio . paused ) audio_animationframe = raf ( audio_timeupdate_handler ) ;
22
23
audio_updating = true ;
23
24
ctx . audio_timeupdate_handler . call ( audio ) ;
24
25
}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import * as path from "path";
3
3
import * as fs from "fs" ;
4
4
import { rollup } from 'rollup' ;
5
5
import * as virtual from 'rollup-plugin-virtual' ;
6
- import { clear_loops , set_now } from "../../internal.js" ;
6
+ import { clear_loops , set_now , set_raf } from "../../internal.js" ;
7
7
8
8
import {
9
9
showOutput ,
@@ -101,15 +101,15 @@ describe("runtime", () => {
101
101
}
102
102
} ;
103
103
set_now ( ( ) => raf . time ) ;
104
- global . requestAnimationFrame = cb => {
104
+ set_raf ( cb => {
105
105
let called = false ;
106
106
raf . callback = ( ) => {
107
107
if ( ! called ) {
108
108
called = true ;
109
109
cb ( ) ;
110
110
}
111
111
} ;
112
- } ;
112
+ } ) ;
113
113
114
114
try {
115
115
mod = require ( `./samples/${ dir } /main.svelte` ) ;
You can’t perform that action at this time.
0 commit comments