Skip to content

Commit a4061a0

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

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
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
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,31 @@ describe('$$rAF', function() {
7676
}
7777
}));
7878
});
79+
80+
describe('mobile', function() {
81+
it('should provide a cancellation method for an older version of Android', function() {
82+
83+
//we need to create our own injector to work around the ngMock overrides
84+
var injector = createInjector(['ng', function($provide) {
85+
$provide.decorator('$window', function($delegate) {
86+
$delegate.requestAnimationFrame = noop;
87+
$delegate.cancelAnimationFrame = false;
88+
$delegate.webkitCancelAnimationFrame = false;
89+
$delegate.mozCancelAnimationFrame = false;
90+
$delegate.webkitCancelRequestAnimationFrame = jasmine.createSpy();
91+
return $delegate;
92+
});
93+
}]);
94+
95+
var $$rAF = injector.get('$$rAF');
96+
var $window = injector.get('$window');
97+
var cancel = $$rAF(function() {});
98+
99+
try {
100+
cancel();
101+
} catch(e) {}
102+
103+
expect($window.webkitCancelRequestAnimationFrame).toHaveBeenCalled();
104+
});
105+
});
79106
});

0 commit comments

Comments
 (0)