Skip to content

fix(progress-circle): remove performance.now to support non browser envs #857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2016
Merged
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
15 changes: 2 additions & 13 deletions src/components/progress-circle/progress-circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class MdProgressCircle implements OnDestroy {
private _animateCircle(animateFrom: number, animateTo: number, ease: EasingFn,
duration: number, rotation: number) {
let id = ++this._lastAnimationId;
let startTime = now();
let startTime = Date.now();
let changeInValue = animateTo - animateFrom;

// No need to animate it if the values are the same
Expand All @@ -160,7 +160,7 @@ export class MdProgressCircle implements OnDestroy {
} else {
let animation = (currentTime: number) => {
let elapsedTime = Math.max(
0, Math.min((currentTime || now()) - startTime, duration));
0, Math.min((currentTime || Date.now()) - startTime, duration));

this.currentPath = getSvgArc(
ease(elapsedTime, animateFrom, changeInValue, duration),
Expand Down Expand Up @@ -246,17 +246,6 @@ function clamp(v: number) {
}


/**
* Returns the current timestamp either based on the performance global or a date object.
*/
function now() {
if (typeof performance !== 'undefined' && performance.now) {
return performance.now();
}
return Date.now();
}


/**
* Converts Polar coordinates to Cartesian.
*/
Expand Down