Widget fixes (#316)

* Use bBox in motor slider

* Use setRate instead of setAngle in gyro widget
This commit is contained in:
Caitlin Hennessy 2018-02-08 16:55:23 -08:00 committed by Sam El-Husseini
parent d8589ea98c
commit 22ce840181
2 changed files with 5 additions and 3 deletions

View File

@ -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;

View File

@ -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));
}
}