Skip to content

Commit 3b3e4ab

Browse files
author
crisbeto
committed
resize element with css and remove $timeout
1 parent 680fe75 commit 3b3e4ab

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/roundProgress.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('angular-svg-round-progress')
4-
.directive('roundProgress', ['$timeout', 'roundProgressService', function($timeout, service){
4+
.directive('roundProgress', ['roundProgressService', function(service){
55

66
if(!service.isSupported){
77
return {
@@ -33,34 +33,31 @@ angular.module('angular-svg-round-progress')
3333
resetValue;
3434

3535
var renderCircle = function(){
36-
$timeout(function(){
37-
var isSemicircle = scope.semi,
38-
radius = parseInt(scope.radius),
39-
stroke = parseInt(scope.stroke);
40-
41-
size = radius*2 + stroke*2;
42-
43-
element.attr({
44-
"width": size,
45-
"height": isSemicircle ? size/2 : size
46-
}).css({
47-
"overflow": "hidden" // on some browsers the background overflows, if in semicircle mode
48-
});
49-
50-
ring.attr({
51-
"stroke": scope.color,
52-
"stroke-width": stroke,
53-
"transform": isSemicircle ? ('translate('+ 0 +','+ size +') rotate(-90)') : ''
54-
});
55-
56-
background.attr({
57-
"cx": radius,
58-
"cy": radius,
59-
"transform": "translate("+ stroke +", "+ stroke +")",
60-
"r": radius,
61-
"stroke": scope.bgcolor,
62-
"stroke-width": stroke
63-
});
36+
var isSemicircle = scope.semi,
37+
radius = parseInt(scope.radius),
38+
stroke = parseInt(scope.stroke);
39+
40+
size = radius*2 + stroke*2;
41+
42+
element.css({
43+
"width": size,
44+
"height": isSemicircle ? size/2 : size,
45+
"overflow": "hidden" // on some browsers the background overflows, if in semicircle mode
46+
});
47+
48+
ring.attr({
49+
"stroke": scope.color,
50+
"stroke-width": stroke,
51+
"transform": isSemicircle ? ('translate('+ 0 +','+ size +') rotate(-90)') : ''
52+
});
53+
54+
background.attr({
55+
"cx": radius,
56+
"cy": radius,
57+
"transform": "translate("+ stroke +", "+ stroke +")",
58+
"r": radius,
59+
"stroke": scope.bgcolor,
60+
"stroke-width": stroke
6461
});
6562
};
6663

@@ -120,7 +117,7 @@ angular.module('angular-svg-round-progress')
120117
template:[
121118
'<svg class="round-progress" xmlns="http://www.w3.org/2000/svg">',
122119
'<circle fill="none"/>',
123-
'<path fill="none" />',
120+
'<path fill="none"/>',
124121
'</svg>'
125122
].join('\n')
126123
};

0 commit comments

Comments
 (0)