Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit 317384b

Browse files
committed
fix($$RAFProvider): check for webkitCancelRequestAnimationFrame.
Android 4.3 only supports webkitCancelRequestAnimationFrame. Closes angular#6526
1 parent d07101d commit 317384b

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/ng/raf.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ function $$RAFProvider(){ //rAF
66
$window.webkitRequestAnimationFrame;
77

88
var cancelAnimationFrame = $window.cancelAnimationFrame ||
9-
$window.webkitCancelAnimationFrame;
9+
$window.webkitCancelAnimationFrame ||
10+
$window.webkitCancelRequestAnimationFrame;
1011

1112
var raf = function(fn) {
1213
var id = requestAnimationFrame(fn);
@@ -19,4 +20,4 @@ function $$RAFProvider(){ //rAF
1920

2021
return raf;
2122
}];
22-
}
23+
}

test/ng/rafSpec.js

+25
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,29 @@ describe('$$rAF', function() {
4444
}
4545
}));
4646
});
47+
48+
describe('mobile', function() {
49+
it('should provide a cancellation method for an older version of Android', function() {
50+
51+
//we need to create our own injector to work around the ngMock overrides
52+
var injector = createInjector(['ng', function($provide) {
53+
$provide.value('$window', {
54+
webkitRequestAnimationFrame: jasmine.createSpy('$window.webkitRequestAnimationFrame'),
55+
webkitCancelRequestAnimationFrame: jasmine.createSpy('$window.webkitCancelRequestAnimationFrame')
56+
});
57+
}]);
58+
59+
var $$rAF = injector.get('$$rAF');
60+
var $window = injector.get('$window');
61+
var cancel = $$rAF(function() {});
62+
63+
expect($$rAF.supported).toBe(true);
64+
65+
try {
66+
cancel();
67+
} catch(e) {}
68+
69+
expect($window.webkitCancelRequestAnimationFrame).toHaveBeenCalled();
70+
});
71+
});
4772
});

0 commit comments

Comments
 (0)