Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e84da22

Browse files
Traxmaxxmatsko
authored andcommitted
fix($$RAFProvider): check for webkitCancelRequestAnimationFrame
Android 4.3 only supports webkitCancelRequestAnimationFrame. Closes #6526
1 parent 3dd9572 commit e84da22

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/ng/raf.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ function $$RAFProvider(){ //rAF
88

99
var cancelAnimationFrame = $window.cancelAnimationFrame ||
1010
$window.webkitCancelAnimationFrame ||
11-
$window.mozCancelAnimationFrame;
11+
$window.mozCancelAnimationFrame ||
12+
$window.webkitCancelRequestAnimationFrame;
1213

1314
var rafSupported = !!requestAnimationFrame;
1415
var raf = rafSupported

test/ng/rafSpec.js

+27-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ describe('$$rAF', function() {
3838
//we need to create our own injector to work around the ngMock overrides
3939
var injector = createInjector(['ng', function($provide) {
4040
$provide.value('$timeout', timeoutSpy);
41-
$provide.decorator('$window', function($delegate) {
42-
$delegate.requestAnimationFrame = false;
43-
$delegate.webkitRequestAnimationFrame = false;
44-
$delegate.mozRequestAnimationFrame = false;
45-
return $delegate;
41+
$provide.value('$window', {
42+
location : window.location,
4643
});
4744
}]);
4845

@@ -76,4 +73,29 @@ describe('$$rAF', function() {
7673
}
7774
}));
7875
});
76+
77+
describe('mobile', function() {
78+
it('should provide a cancellation method for an older version of Android', function() {
79+
//we need to create our own injector to work around the ngMock overrides
80+
var injector = createInjector(['ng', function($provide) {
81+
$provide.value('$window', {
82+
location : window.location,
83+
webkitRequestAnimationFrame: jasmine.createSpy('$window.webkitRequestAnimationFrame'),
84+
webkitCancelRequestAnimationFrame: jasmine.createSpy('$window.webkitCancelRequestAnimationFrame')
85+
});
86+
}]);
87+
88+
var $$rAF = injector.get('$$rAF');
89+
var $window = injector.get('$window');
90+
var cancel = $$rAF(function() {});
91+
92+
expect($$rAF.supported).toBe(true);
93+
94+
try {
95+
cancel();
96+
} catch(e) {}
97+
98+
expect($window.webkitCancelRequestAnimationFrame).toHaveBeenCalled();
99+
});
100+
});
79101
});

0 commit comments

Comments
 (0)