37 this.request_animate(); |
37 this.request_animate(); |
38 } |
38 } |
39 |
39 |
40 get_ratios() { |
40 get_ratios() { |
41 let range = this.range; |
41 let range = this.range; |
42 let size = Math.max(this.range * this.mincursize, Math.min(this.size, range)); |
42 let size = Math.max(range * this.mincursize, Math.min(this.size, range)); |
43 let maxh = this.range_elt.height.baseVal.value; |
43 let maxh = this.range_elt.height.baseVal.value; |
44 let pixels = maxh; |
44 let pixels = maxh; |
45 let units = range; |
45 return [size, maxh, range, pixels]; |
46 return [size, maxh, range, pixels, units]; |
|
47 } |
46 } |
48 |
47 |
49 animate(){ |
48 animate(){ |
50 if(this.position == undefined || this.range == undefined || this.size == undefined) |
49 if(this.position == undefined || this.range == undefined || this.size == undefined) |
51 return; |
50 return; |
52 let [size, maxh, range, pixels, units] = this.get_ratios(); |
51 let [size, maxh, range, pixels] = this.get_ratios(); |
53 |
52 |
54 let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / units); |
53 let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / range); |
55 let new_height = Math.round(maxh * size/range); |
54 let new_height = Math.round(maxh * size/range); |
56 |
55 |
57 this.cursor_elt.y.baseVal.value = new_y; |
56 this.cursor_elt.y.baseVal.value = new_y; |
58 this.cursor_elt.height.baseVal.value = new_height; |
57 this.cursor_elt.height.baseVal.value = new_height; |
59 } |
58 } |
92 svg_root.removeEventListener("pointerup", this.bound_drop, true); |
91 svg_root.removeEventListener("pointerup", this.bound_drop, true); |
93 svg_root.removeEventListener("pointermove", this.bound_drag, true); |
92 svg_root.removeEventListener("pointermove", this.bound_drag, true); |
94 } |
93 } |
95 |
94 |
96 drag(e) { |
95 drag(e) { |
97 let [size, maxh, range, pixels, units] = this.get_ratios(); |
96 let [size, maxh, range, pixels] = this.get_ratios(); |
98 if(pixels == 0) return; |
97 if(pixels == 0) return; |
99 let point = new DOMPoint(e.movementX, e.movementY); |
98 let point = new DOMPoint(e.movementX, e.movementY); |
100 let movement = point.matrixTransform(this.invctm).y; |
99 let movement = point.matrixTransform(this.invctm).y; |
101 this.dragpos += movement * units / pixels; |
100 this.dragpos += movement * range / pixels; |
102 this.apply_position(this.dragpos); |
101 this.apply_position(this.dragpos); |
103 } |
102 } |
104 || |
103 || |
105 } |
104 } |
106 |
105 |