File tree 1 file changed +6
-26
lines changed
1 file changed +6
-26
lines changed Original file line number Diff line number Diff line change @@ -14,31 +14,11 @@ export function filterNullChildren(children) {
14
14
return children && children . filter ( i => i !== null ) ;
15
15
}
16
16
17
- export const requestAnimationFrame = ( ( ) => {
18
- let raf ;
19
-
20
- if ( typeof window !== 'undefined' ) {
21
- raf = window . requestAnimationFrame ;
22
- const prefixes = [ 'ms' , 'moz' , 'webkit' , 'o' ] ;
23
- for ( let i = 0 ; i < prefixes . length ; i ++ ) {
24
- if ( raf ) break ;
25
- raf = window [ `${ prefixes [ i ] } RequestAnimationFrame}` ] ;
26
- }
17
+ export const requestAnimationFrame = ( callback ) => {
18
+ if ( typeof window !== 'undefined' && window . requestAnimationFrame ) {
19
+ window . requestAnimationFrame ( callback ) ;
27
20
}
28
-
29
- if ( ! raf ) {
30
- let timeLast = 0 ;
31
- raf = ( callback ) => {
32
- const timeCurrent = new Date ( ) . getTime ( ) ;
33
-
34
- /* Dynamically set the delay on a per-tick basis to more closely match 60fps. */
35
- /* Technique by Erik Moller. MIT license: https://gist.github.com/paulirish/1579671. */
36
- const timeDelta = Math . max ( 0 , 16 - ( timeCurrent - timeLast ) ) ;
37
- timeLast = timeCurrent + timeDelta ;
38
-
39
- return setTimeout ( ( ) => { callback ( timeCurrent + timeDelta ) ; } , timeDelta ) ;
40
- } ;
21
+ else {
22
+ setTimeout ( callback , 17 ) ;
41
23
}
42
-
43
- return raf ;
44
- } ) ( ) ;
24
+ } ;
You can’t perform that action at this time.
0 commit comments