| author | ymh <ymh.work@gmail.com> |
| Sun, 12 Nov 2017 22:07:33 +0100 | |
| changeset 1071 | 02c04d2c8fd8 |
| parent 1021 | 7253d4d06f0d |
| child 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
| 876 | 1 |
IriSP.Widgets.Arrow = function(player, config) { |
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
| 880 | 3 |
this.current_pilot_widget = this.pilot_widget |
| 876 | 4 |
}; |
5 |
||
6 |
IriSP.Widgets.Arrow.prototype = new IriSP.Widgets.Widget(); |
|
7 |
||
8 |
IriSP.Widgets.Arrow.prototype.defaults = { |
|
| 965 | 9 |
arrow_height : 12, |
10 |
arrow_width : 20, |
|
| 880 | 11 |
base_height : 0, |
| 876 | 12 |
base_curve : 0, |
13 |
fill_url: IriSP.widgetsDir + '/img/pinstripe.png', |
|
| 880 | 14 |
fill_color: "#ffffff", //Gradients can be used, e.g. "90-#000-#fff" for vertical white-to-black |
15 |
stroke_color: "#b7b7b7", |
|
16 |
stroke_width: 1.5, |
|
| 965 | 17 |
animation_speed: 20 |
| 1013 | 18 |
}; |
| 876 | 19 |
|
20 |
IriSP.Widgets.Arrow.prototype.draw = function() { |
|
21 |
this.height = this.arrow_height + this.base_height; |
|
| 882 | 22 |
this.$.addClass("Ldt-Arrow").css({ |
| 965 | 23 |
height: (1+this.height) + "px", |
24 |
"margin-top": "1px", |
|
25 |
overflow: "hidden" |
|
| 882 | 26 |
}); |
| 965 | 27 |
this.paper = new Raphael(this.container, this.width, 1+this.height ); |
|
1021
7253d4d06f0d
update widgets after enhance in annotation platform.
cavaliet
parents:
1017
diff
changeset
|
28 |
window.myArrow = this; |
| 880 | 29 |
this.svgArrow = this.paper.path('M0,' + this.height + 'L' + this.width + ',' + this.height); |
30 |
this.svgArrow.attr({ |
|
31 |
stroke: this.stroke_color, |
|
32 |
"stroke-width": this.stroke_width, |
|
| 876 | 33 |
fill: this.fill_url ? ( 'url(' + this.fill_url + ')' ) : this.fill_color |
34 |
}); |
|
| 965 | 35 |
this.moveToX(0); |
| 1013 | 36 |
}; |
| 876 | 37 |
|
38 |
IriSP.Widgets.Arrow.prototype.drawAt = function(_x) { |
|
| 965 | 39 |
_x = Math.max(0, Math.min(_x, this.width)); |
| 876 | 40 |
var _d = 'M0,' + this.height |
41 |
+ 'L0,' + Math.min( this.height, this.arrow_height + this.base_curve) |
|
42 |
+ 'Q0,' + this.arrow_height |
|
43 |
+ ' ' + Math.max(0, Math.min(this.base_curve, _x - this.arrow_width / 2)) + ',' + this.arrow_height |
|
44 |
+ 'L' + Math.max(0, _x - this.arrow_width / 2) + ',' + this.arrow_height |
|
45 |
+ 'L' + Math.max(0, _x - this.arrow_width / 2) + ',' + Math.min(this.arrow_height, 2 * this.arrow_height * _x / this.arrow_width) |
|
46 |
+ 'L' + _x + ',0' |
|
47 |
+ 'L' + Math.min(this.width, _x + this.arrow_width / 2) + ',' + Math.min(this.arrow_height, 2 * this.arrow_height * ( this.width - _x ) / this.arrow_width) |
|
48 |
+ 'L' + Math.min(this.width, _x + this.arrow_width / 2) + ',' + this.arrow_height |
|
49 |
+ 'L' + Math.min(this.width, Math.max(this.width - this.base_curve, _x + this.arrow_width / 2)) + ',' + this.arrow_height |
|
50 |
+ 'Q' + this.width + ',' + this.arrow_height |
|
51 |
+ ' ' + this.width + ',' + Math.min( this.height, this.arrow_height + this.base_curve) |
|
52 |
+ 'L' + this.width + ',' + this.height; |
|
| 880 | 53 |
this.svgArrow.attr({ |
| 876 | 54 |
path: _d |
55 |
}); |
|
| 1013 | 56 |
}; |
| 876 | 57 |
|
| 965 | 58 |
IriSP.Widgets.Arrow.prototype.moveToX = function(_x) { |
59 |
this.targetX = Math.max(0, Math.min(_x, this.width)); |
|
| 876 | 60 |
if (typeof this.animInterval === "undefined") { |
61 |
this.animInterval = window.setInterval( |
|
62 |
this.functionWrapper("increment"), |
|
63 |
40 |
|
| 1013 | 64 |
); |
| 876 | 65 |
} |
66 |
this.increment(); |
|
| 1013 | 67 |
}; |
| 876 | 68 |
|
| 965 | 69 |
IriSP.Widgets.Arrow.prototype.moveToTime = function(_t) { |
70 |
this.moveToX(this.width * _t / this.media.duration); |
|
| 1013 | 71 |
}; |
| 965 | 72 |
|
| 876 | 73 |
IriSP.Widgets.Arrow.prototype.increment = function() { |
74 |
if (typeof this.currentX === "undefined") { |
|
75 |
this.currentX = this.targetX; |
|
76 |
} |
|
77 |
if (this.currentX < this.targetX) { |
|
78 |
this.currentX = Math.min(this.targetX, this.currentX + this.animation_speed); |
|
79 |
} |
|
80 |
if (this.currentX > this.targetX) { |
|
81 |
this.currentX = Math.max(this.targetX, this.currentX - this.animation_speed); |
|
82 |
} |
|
83 |
if (this.currentX === this.targetX) { |
|
84 |
window.clearInterval(this.animInterval); |
|
85 |
this.animInterval = undefined; |
|
86 |
} |
|
87 |
this.drawAt(this.currentX); |
|
| 1013 | 88 |
}; |