|
1 | | -/* [email protected].9 2015-12-27 */ |
| 1 | +/* [email protected].10 2016-01-23 */ |
2 | 2 | // shim layer with setTimeout fallback |
3 | 3 | // credit Erik Möller and http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ |
4 | 4 | 'use strict'; |
@@ -331,6 +331,7 @@ angular.module('angular-svg-round-progress') |
331 | 331 | rounded: "=", |
332 | 332 | clockwise: "=", |
333 | 333 | responsive: "=", |
| 334 | + onRender: "=", |
334 | 335 | radius: "@", |
335 | 336 | color: "@", |
336 | 337 | bgcolor: "@", |
@@ -441,20 +442,23 @@ angular.module('angular-svg-round-progress') |
441 | 442 | // stops some expensive animating if the value is above the max or under 0 |
442 | 443 | if(preventAnimation){ |
443 | 444 | service.updateState(end, max, circleSize, ring, elementSize, isSemicircle); |
| 445 | + |
| 446 | + if(options.onRender){ |
| 447 | + options.onRender(end, options, element); |
| 448 | + } |
444 | 449 | }else{ |
445 | 450 | var startTime = new $window.Date(); |
446 | 451 | var id = ++lastAnimationId; |
447 | 452 |
|
448 | 453 | (function animation(){ |
449 | 454 | var currentTime = $window.Math.min(new Date() - startTime, duration); |
| 455 | + var animateTo = easingAnimation(currentTime, start, changeInValue, duration); |
| 456 | + |
| 457 | + service.updateState(animateTo, max, circleSize, ring, elementSize, isSemicircle); |
450 | 458 |
|
451 | | - service.updateState( |
452 | | - easingAnimation(currentTime, start, changeInValue, duration), |
453 | | - max, |
454 | | - circleSize, |
455 | | - ring, |
456 | | - elementSize, |
457 | | - isSemicircle); |
| 459 | + if(options.onRender){ |
| 460 | + options.onRender(animateTo, options, element); |
| 461 | + } |
458 | 462 |
|
459 | 463 | if(id === lastAnimationId && currentTime < duration){ |
460 | 464 | $window.requestAnimationFrame(animation); |
@@ -499,7 +503,7 @@ angular.module('angular-svg-round-progress') |
499 | 503 |
|
500 | 504 | // properties that are used during animation. some of these overlap with |
501 | 505 | // the ones that are used for presentation |
502 | | - scope.$watchGroup(['current', 'max', 'animation', 'duration', 'radius', 'stroke', 'semi', 'offset'], function(newValue, oldValue){ |
| 506 | + scope.$watchGroup(['current', 'max', 'radius', 'stroke', 'semi', 'offset'], function(newValue, oldValue){ |
503 | 507 | renderState(service.toNumber(newValue[0]), service.toNumber(oldValue[0])); |
504 | 508 | }); |
505 | 509 | }, |
|
0 commit comments