-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress.js
64 lines (50 loc) · 1.69 KB
/
progress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
goog.provide('dm.Progress');
goog.require('lime.RoundedRect');
goog.require('lime.animation.Resize');
goog.require('lime.fill.LinearGradient');
/**
* Progressbar
* @constructor
* @extends lime.RoundedRect
*/
dm.Progress = function(initv,icolor,width,height,radius,border,bcolor) {
lime.RoundedRect.call(this);
var WIDTH = width || 320,
HEIGHT = height ||50,
RADIUS = radius ||20,
BORDER = border ||8;
icolor = icolor || '#FF0000';
bcolor = bcolor || '#00FF00';
this.setSize(WIDTH, HEIGHT).setRadius(RADIUS).setAnchorPoint(0, 0);
this.setFill(new lime.fill.LinearGradient().addColorStop(0, 0, 0, 0, .6).addColorStop(1, 0x1e, 0x57, 0x97, .4));
WIDTH -= 2 * BORDER;
HEIGHT -= 2 * BORDER;
RADIUS -= BORDER ;
initv = initv || 1;
// inner balue var
var inner = new lime.RoundedRect().setRadius(RADIUS).setSize(WIDTH*initv, HEIGHT).setFill(icolor).
setAnchorPoint(0, 0).setPosition(BORDER, BORDER);
this.appendChild(inner);
/*
inner.setFill(new lime.fill.LinearGradient().addColorStop(0, '#afcdef').addColorStop(.49, '#55a1fc').
addColorStop(.5, '#3690f4').addColorStop(1, '#8dc9ff'));
*/
this.width = WIDTH;
this.inner = inner;
};
goog.inherits(dm.Progress, lime.RoundedRect);
/**
* Set current progress value
* @param {number} value Current progress value.
*/
dm.Progress.prototype.setProgress = function(value) {
this.porgress_ = value;
this.inner.runAction(new lime.animation.Resize(this.width * value, this.inner.getSize().height).setDuration(.4));
};
/**
* Return current progress value
* @return {number} value.
*/
dm.Progress.prototype.getProgress = function() {
return this.progress_;
};