From d0f1ec26eb4400f1a85f9ec7b30f07cc4c51aa28 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Sat, 6 Aug 2016 08:53:40 +0300 Subject: [PATCH] fix(progressCircular): better support for older ios versions * Fixes the indeterminate animation not working on certain iOS versions which pass in the `DOMHighResTimestamp` to `requestAnimationFrame`, but don't support `performance.now`. * Adds fallbacks to the prefixed versions of `requestAnimationFrame`. Fixes #9253. --- .../js/progressCircularDirective.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/progressCircular/js/progressCircularDirective.js b/src/components/progressCircular/js/progressCircularDirective.js index 566d32009af..9422d6801f6 100644 --- a/src/components/progressCircular/js/progressCircularDirective.js +++ b/src/components/progressCircular/js/progressCircularDirective.js @@ -53,8 +53,15 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming, // Note that this shouldn't use use $$rAF, because it can cause an infinite loop // in any tests that call $animate.flush. - var rAF = $window.requestAnimationFrame || angular.noop; - var cAF = $window.cancelAnimationFrame || angular.noop; + var rAF = $window.requestAnimationFrame || + $window.webkitRequestAnimationFrame || + angular.noop; + + var cAF = $window.cancelAnimationFrame || + $window.webkitCancelAnimationFrame || + $window.webkitCancelRequestAnimationFrame || + angular.noop; + var DEGREE_IN_RADIANS = $window.Math.PI / 180; var MODE_DETERMINATE = 'determinate'; var MODE_INDETERMINATE = 'indeterminate'; @@ -208,8 +215,8 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming, if (animateTo === animateFrom) { path.attr('d', getSvgArc(animateTo, diameter, pathDiameter, rotation)); } else { - lastDrawFrame = rAF(function animation(now) { - var currentTime = $window.Math.max(0, $window.Math.min((now || $mdUtil.now()) - startTime, animationDuration)); + lastDrawFrame = rAF(function animation() { + var currentTime = $window.Math.max(0, $window.Math.min($mdUtil.now() - startTime, animationDuration)); path.attr('d', getSvgArc( ease(currentTime, animateFrom, changeInValue, animationDuration),