This repository was archived by the owner on Mar 1, 2025. It is now read-only.
File tree 2 files changed +42
-13
lines changed
2 files changed +42
-13
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- function $$RAFProvider ( ) { //rAF
4
- this . $get = [ '$window' , function ( $window ) {
5
- var requestAnimationFrame = $window . requestAnimationFrame ||
6
- $window . webkitRequestAnimationFrame ;
3
+ function createRAF ( $window ) {
4
+ var requestAnimationFrame = $window . requestAnimationFrame ||
5
+ $window . webkitRequestAnimationFrame ;
7
6
8
- var cancelAnimationFrame = $window . cancelAnimationFrame ||
9
- $window . webkitCancelAnimationFrame ;
7
+ var cancelAnimationFrame = $window . cancelAnimationFrame ||
8
+ $window . webkitCancelAnimationFrame ||
9
+ $window . webkitCancelRequestAnimationFrame ;
10
10
11
- var raf = function ( fn ) {
12
- var id = requestAnimationFrame ( fn ) ;
13
- return function ( ) {
14
- cancelAnimationFrame ( id ) ;
15
- } ;
11
+ var raf = function ( fn ) {
12
+ var id = requestAnimationFrame ( fn ) ;
13
+ return function ( ) {
14
+ cancelAnimationFrame ( id ) ;
16
15
} ;
16
+ } ;
17
+
18
+ raf . supported = ! ! requestAnimationFrame ;
17
19
18
- raf . supported = ! ! requestAnimationFrame ;
20
+ return raf ;
21
+ }
19
22
20
- return raf ;
23
+ function $$RAFProvider ( ) { //rAF
24
+ this . $get = [ '$window' , function ( $window ) {
25
+ return createRAF ( $window ) ;
21
26
} ] ;
22
27
}
Original file line number Diff line number Diff line change @@ -44,4 +44,28 @@ describe('$$rAF', function() {
44
44
}
45
45
} ) ) ;
46
46
} ) ;
47
+
48
+ describe ( 'mobile' , function ( ) {
49
+ var $window ;
50
+
51
+ it ( 'should provide a cancellation method for an older version of Android' , function ( ) {
52
+ module ( function ( $provide ) {
53
+ $provide . value ( '$window' , {
54
+ webkitRequestAnimationFrame : jasmine . createSpy ( '$window.webkitRequestAnimationFrame' ) ,
55
+ webkitCancelRequestAnimationFrame : jasmine . createSpy ( '$window.webkitCancelRequestAnimationFrame' )
56
+ } ) ;
57
+ } ) ;
58
+
59
+ inject ( function ( $window ) {
60
+ var $raf = createRAF ( $window ) ;
61
+ var cancel = $raf ( function ( ) { } ) ;
62
+
63
+ try {
64
+ cancel ( ) ;
65
+ } catch ( e ) { }
66
+
67
+ expect ( $window . webkitCancelRequestAnimationFrame ) . toHaveBeenCalled ( ) ;
68
+ } ) ;
69
+ } ) ;
70
+ } ) ;
47
71
} ) ;
You can’t perform that action at this time.
0 commit comments