Skip to content

Commit c3f032f

Browse files
author
crisbeto
committed
0.2.0 release. Adds:
- Dynamic binding - Animation presets and ability to choose animation - Some file reorganization
1 parent 4959516 commit c3f032f

File tree

13 files changed

+717
-259
lines changed

13 files changed

+717
-259
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
bower_components/
22
node_modules/
3-
build/
43
.DS_Store
54
.grunt/

Gruntfile.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
module.exports = function(grunt) {
2+
var files = [
3+
'src/shim.js',
4+
'src/module.js',
5+
'src/roundProgressService.js',
6+
'src/roundProgress.js',
7+
];
8+
29
grunt.initConfig({
310
pkg: grunt.file.readJSON('package.json'),
411
'uglify': {
512
'options': {
613
'banner': '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
714
},
815
'build': {
9-
'src': 'roundProgress.js',
16+
'src': files,
1017
'dest': 'build/roundProgress.min.js'
1118
}
1219
},
13-
'copy': {
14-
'deploy': {
15-
'files': [{
16-
'src': ['demo.html'],
17-
'dest': 'build/index.html'
18-
}, {
19-
'src': ['roundProgress.js'],
20-
'dest': 'build/'
21-
}]
20+
'concat': {
21+
'options': {
22+
separator: '\n',
23+
},
24+
'build': {
25+
src: files,
26+
dest: 'build/roundProgress.js',
2227
}
2328
},
2429
'gh-pages': {
@@ -32,9 +37,9 @@ module.exports = function(grunt) {
3237
});
3338

3439
grunt.loadNpmTasks('grunt-contrib-uglify');
35-
grunt.loadNpmTasks('grunt-contrib-copy');
40+
grunt.loadNpmTasks('grunt-contrib-concat');
3641
grunt.loadNpmTasks('grunt-gh-pages');
3742

38-
grunt.registerTask('default', ['uglify:build', 'copy:deploy']);
43+
grunt.registerTask('default', ['concat:build', 'uglify:build']);
3944
grunt.registerTask('deploy', ['default', 'gh-pages:deploy']);
4045
};

README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AngularJS module that uses SVG to create a circular progressbar
66

77
## Install
88

9-
Include Angular and `roundProgress.js` or `roundProgress.min.js` in your page. You can use bower, or a script-tag:
9+
Include Angular and [roundProgress.min.js](https://raw.githubusercontent.com/crisbeto/angular-svg-round-progressbar/master/build/roundProgress.min.js) or [roundProgress.js](https://raw.githubusercontent.com/crisbeto/angular-svg-round-progressbar/master/build/roundProgress.js) in your page. You can use bower, or a script-tag:
1010

1111
`bower install angular-svg-round-progressbar`
1212

@@ -31,25 +31,44 @@ angular.module('someModule', ['angular-svg-round-progress'])
3131
* `stroke` specifies the thickness of the line
3232
* `semi` boolean, specifies whether the progressbar should be a semicircle or a full circle
3333
* `iterations` number of iterations for the animation. Set it to 1 for *no animation* and increase for slower animation. *(Optional, 50 by default)*
34-
* To manually trigger a complete re-render of the progressbar, broadcast a "renderCircle" from a parent scope:
35-
36-
```javascript
37-
$rootScope.$broadcast('renderCircle');
38-
```
34+
* `animation` the easing function that will be used. Default value is `easeOutCubic`, possible values:
35+
* linearEase
36+
* easeInQuad
37+
* easeOutQuad
38+
* easeInOutQuad
39+
* easeInCubic
40+
* easeOutCubic
41+
* easeInOutCubic
42+
* easeInQuart
43+
* easeOutQuart
44+
* easeInOutQuart
45+
* easeInQuint
46+
* easeOutQuint
47+
* easeInOutQuint
48+
* easeInSine
49+
* easeOutSine
50+
* easeInOutSine
51+
* easeInExpo
52+
* easeOutExpo
53+
* easeInOutExpo
54+
* easeInCirc
55+
* easeOutCirc
56+
* easeInOutCirc
3957

4058
### Example:
4159

4260
```html
4361
<div
44-
round-progress
45-
max="max"
46-
current="current"
47-
color="#45ccce"
48-
bgcolor="#eaeaea"
49-
radius="100"
50-
stroke="20"
51-
semi="true">
52-
</div>
62+
round-progress
63+
max="max"
64+
current="current"
65+
color="#45ccce"
66+
bgcolor="#eaeaea"
67+
radius="100"
68+
stroke="20"
69+
semi="true"
70+
iterations="50"
71+
animation="easeInOutQuart"></div>
5372
```
5473

5574
## Browser support

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-svg-round-progressbar",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"homepage": "https://github.com/crisbeto/angular-svg-round-progressbar",
55
"authors": [
66
"crisbeto"
@@ -21,5 +21,5 @@
2121
"dependencies": {
2222
"angular": "~1.2.19"
2323
},
24-
"main":"roundProgress.js"
24+
"main":"build/roundProgress.min.js"
2525
}

demo.html renamed to build/index.html

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<!doctype html>
3-
<html lang="en">
3+
<html lang="en" ng-app="demo">
44
<head>
55
<meta charset="UTF-8">
66
<title>Angular SVG round progressbar demo</title>
@@ -57,15 +57,15 @@
5757

5858
form{
5959
text-align: left;
60-
width: 270px;
60+
width: 300px;
6161
margin:20px auto;
6262
}
6363

6464
form > div{
6565
margin-bottom: 5px;
6666
}
6767

68-
input{
68+
input, select{
6969
float:right;
7070
padding: 5px;
7171
}
@@ -77,8 +77,8 @@
7777
}
7878
</style>
7979
</head>
80-
<body ng-app="demo">
81-
<div class="container" ng-controller="demoCtrl">
80+
<body ng-controller="demoCtrl">
81+
<div class="container">
8282
<a class="back" href="https://github.com/crisbeto/angular-svg-round-progressbar">Back to project repo</a>
8383

8484
<h2>Sample progressbar</h2>
@@ -93,7 +93,8 @@ <h2>Sample progressbar</h2>
9393
radius="{{ radius }}"
9494
semi="isSemi"
9595
stroke="{{ stroke }}"
96-
iterations="{{ iterations }}">
96+
iterations="{{ iterations }}"
97+
animation="{{ currentAnimation }}">
9798
</div>
9899
</div>
99100

@@ -131,6 +132,16 @@ <h3>Customize!</h3>
131132
<input type="number" ng-model="radius"/>
132133
</div>
133134

135+
<div class="cf">
136+
<label>Iterations:</label>
137+
<input type="number" ng-model="iterations"/>
138+
</div>
139+
140+
<div class="cf">
141+
<label>Animation:</label>
142+
<select ng-model="currentAnimation" ng-options="animation for animation in animations"></select>
143+
</div>
144+
134145
<div class="cf">
135146
<label>Color:</label>
136147
<input type="color" ng-model="currentColor"/>
@@ -140,28 +151,23 @@ <h3>Customize!</h3>
140151
<label>Background color:</label>
141152
<input type="color" ng-model="bgColor"/>
142153
</div>
143-
144-
<div class="cf">
145-
<label>Iterations:</label>
146-
<input type="number" ng-model="iterations"/>
147-
</div>
148154
</form>
149155
</div>
150156

151-
<div class="container" ng-controller="demoCtrl">
157+
<div class="container">
152158
<h2>Upload progress example</h2>
153159
<div class="progress-wrapper">
154-
<div class="progress">{{ ((uploadCurrent/100)*100) | number:0 }}%</div>
160+
<div class="progress" ng-style="{'font-size': ((radius + stroke)/(isSemi ? 3.5 : 3))+'px'}">{{ ((uploadCurrent/100)*100) | number:0 }}%</div>
155161
<div
156162
round-progress
157163
max="100"
158164
current="uploadCurrent"
159-
color="#45ccce"
160-
bgcolor="#eaeaea"
161-
radius="100"
165+
color="{{ currentColor }}"
166+
bgcolor="{{ bgColor }}"
167+
radius="{{ radius }}"
162168
semi="isSemi"
163-
stroke="15">
164-
</div>
169+
stroke="{{ stroke }}"
170+
animation="{{ currentAnimation }}"></div>
165171
</div>
166172

167173
<button ng-click="start();">Start</button>
@@ -170,20 +176,22 @@ <h2>Upload progress example</h2>
170176
</div>
171177

172178

173-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
179+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.js"></script>
174180
<script src="roundProgress.js"></script>
175181
<script>
176182
angular.module('demo', ['angular-svg-round-progress'])
177-
.controller('demoCtrl', ['$scope', '$timeout', '$rootScope', function($scope, $timeout, $rootScope){
178-
179-
$scope.current = 27,
180-
$scope.max = 50,
181-
$scope.uploadCurrent = 0,
182-
$scope.stroke = 15,
183-
$scope.radius = 100,
184-
$scope.isSemi = false,
185-
$scope.currentColor = '#45ccce',
186-
$scope.bgColor = '#eaeaea'
183+
.controller('demoCtrl', ['$scope', '$timeout', 'roundProgressService', function($scope, $timeout, roundProgressService){
184+
185+
$scope.current = 27;
186+
$scope.max = 50;
187+
$scope.uploadCurrent = 0;
188+
$scope.stroke = 15;
189+
$scope.radius = 100;
190+
$scope.isSemi = false;
191+
$scope.currentColor = '#45ccce';
192+
$scope.bgColor = '#eaeaea';
193+
$scope.iterations = 50;
194+
$scope.currentAnimation = 'easeOutCubic';
187195

188196
var random = function(min, max){
189197
return Math.round(Math.floor(Math.random()*(max-min+1)+min));
@@ -194,10 +202,6 @@ <h2>Upload progress example</h2>
194202
$scope.current+=(amount || 1);
195203
};
196204

197-
$scope.$watchCollection('[max, stroke, radius, isSemi, currentColor, bgColor, iterations]', function(newValue, oldValue){
198-
$rootScope.$broadcast('renderCircle');
199-
});
200-
201205
$scope.decrement = function(amount){
202206
$scope.current-=(amount || 1);
203207
};
@@ -210,7 +214,7 @@ <h2>Upload progress example</h2>
210214
if($scope.uploadCurrent < 100){
211215
$scope.start();
212216
}
213-
}, random(300, 500));
217+
}, random(100, 500));
214218
};
215219

216220
$scope.stop = function(){
@@ -222,6 +226,11 @@ <h2>Upload progress example</h2>
222226
$scope.uploadCurrent = 0;
223227
};
224228

229+
$scope.animations = [];
230+
231+
angular.forEach(roundProgressService.animations, function(value, key){
232+
$scope.animations.push(key);
233+
});
225234
}]);
226235
</script>
227236
</body>

0 commit comments

Comments
 (0)