Widget fixes (#316)
* Use bBox in motor slider * Use setRate instead of setAngle in gyro widget
This commit is contained in:
parent
d8589ea98c
commit
22ce840181
@ -86,9 +86,11 @@ namespace pxsim.visuals {
|
||||
private prevVal: number;
|
||||
private updateSliderValue(pt: SVGPoint, parent: SVGSVGElement, ev: MouseEvent) {
|
||||
let cur = svg.cursorPoint(pt, parent, ev);
|
||||
let bBox = this.content.getBoundingClientRect();
|
||||
|
||||
const coords = {
|
||||
x: cur.x / this.scaleFactor - this.left / this.scaleFactor,
|
||||
y: cur.y / this.scaleFactor - this.top / this.scaleFactor
|
||||
x: cur.x / this.scaleFactor - bBox.left / this.scaleFactor,
|
||||
y: cur.y / this.scaleFactor - bBox.top / this.scaleFactor
|
||||
};
|
||||
const radius = MotorSliderControl.SLIDER_RADIUS / 2;
|
||||
const dx = coords.x - radius;
|
||||
|
@ -76,7 +76,7 @@ namespace pxsim.visuals {
|
||||
let t = Math.max(0, Math.min(1, (width + bBox.left / this.scaleFactor - cur.x / this.scaleFactor) / width))
|
||||
|
||||
const state = this.state;
|
||||
state.setAngle((1 - t) * (100));
|
||||
state.setRate((1 - t) * (100));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user