equal
deleted
inserted
replaced
10 mincursize = 0.1; |
10 mincursize = 0.1; |
11 |
11 |
12 dispatch(value,oldval, index) { |
12 dispatch(value,oldval, index) { |
13 switch(index) { |
13 switch(index) { |
14 case 0: |
14 case 0: |
15 if (Math.round(this.position) != value) |
15 this.position = value; |
16 this.position = value; |
|
17 break; |
16 break; |
18 case 1: |
17 case 1: |
19 this.range = value; |
18 this.range = Math.max(1,value); |
20 break; |
19 break; |
21 case 2: |
20 case 2: |
22 this.size = value; |
21 this.size = value; |
23 break; |
22 break; |
24 } |
23 } |
53 this.bound_drag = this.drag.bind(this); |
52 this.bound_drag = this.drag.bind(this); |
54 this.bound_drop = this.drop.bind(this); |
53 this.bound_drop = this.drop.bind(this); |
55 } |
54 } |
56 |
55 |
57 apply_position(position){ |
56 apply_position(position){ |
58 this.position = Math.max(Math.min(position, this.range), 0); |
57 this.position = Math.round(Math.max(Math.min(position, this.range), 0)); |
59 this.apply_hmi_value(0, Math.round(this.position)); |
58 this.apply_hmi_value(0, this.position); |
60 } |
59 } |
61 |
60 |
62 on_page_click(is_up){ |
61 on_page_click(is_up){ |
63 this.apply_position(is_up ? this.position-this.size |
62 this.apply_position(is_up ? this.position-this.size |
64 : this.position+this.size); |
63 : this.position+this.size); |
72 ctm.f = 0; |
71 ctm.f = 0; |
73 // root -> scrollbar transform |
72 // root -> scrollbar transform |
74 this.invctm = ctm.inverse(); |
73 this.invctm = ctm.inverse(); |
75 svg_root.addEventListener("pointerup", this.bound_drop, true); |
74 svg_root.addEventListener("pointerup", this.bound_drop, true); |
76 svg_root.addEventListener("pointermove", this.bound_drag, true); |
75 svg_root.addEventListener("pointermove", this.bound_drag, true); |
|
76 this.dragpos = this.position; |
77 } |
77 } |
78 |
78 |
79 drop(e) { |
79 drop(e) { |
80 svg_root.removeEventListener("pointerup", this.bound_drop, true); |
80 svg_root.removeEventListener("pointerup", this.bound_drop, true); |
81 svg_root.removeEventListener("pointermove", this.bound_drag, true); |
81 svg_root.removeEventListener("pointermove", this.bound_drag, true); |
84 drag(e) { |
84 drag(e) { |
85 let [size, maxh, range, pixels, units] = this.get_ratios(); |
85 let [size, maxh, range, pixels, units] = this.get_ratios(); |
86 if(pixels == 0) return; |
86 if(pixels == 0) return; |
87 let point = new DOMPoint(e.movementX, e.movementY); |
87 let point = new DOMPoint(e.movementX, e.movementY); |
88 let movement = point.matrixTransform(this.invctm).y; |
88 let movement = point.matrixTransform(this.invctm).y; |
89 this.apply_position(this.position + movement * units / pixels); |
89 this.dragpos += movement * units / pixels; |
|
90 this.apply_position(this.dragpos); |
90 } |
91 } |
91 } |
92 } |
92 || |
93 || |
93 } |
94 } |
94 |
95 |