Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(progressCircular): rAF is still running when using ng-show or ng-hide #10745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/progressCircular/js/progressCircularDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,23 @@ function MdProgressCircularDirective($window, $mdProgressCircular, $mdTheming,

});


// When using ng-show or ng-hide,
// the animation won't stop because requestAnimationFrame is still running.
// Do this to stop requestAnimationFrame can save some usage of system resources.
scope.$watch(function() {
var style = $window.getComputedStyle(node);
return style && style.display;
}, function(newValue, oldValue) {
if(newValue && newValue !== oldValue) {
if(newValue === 'none') {
cleanupIndeterminateAnimation();
} else {
startIndeterminateAnimation();
}
}
});

function renderCircle(animateFrom, animateTo, easing, duration, iterationCount, maxValue) {
var id = ++lastAnimationId;
var startTime = $mdUtil.now();
Expand Down