Snap backwards (#923)
* snap to multiple of 5 * normalize negative values
This commit is contained in:
@ -76,9 +76,12 @@ export class FieldSpeed extends Blockly.FieldSlider implements Blockly.FieldCust
|
||||
};
|
||||
|
||||
setReadout_(readout: Element, value: string) {
|
||||
this.updateSpeed(parseFloat(value));
|
||||
let x = parseFloat(value) || 0;
|
||||
// snap on multiple of 5
|
||||
x = Math.round(x / 5) * 5;
|
||||
this.updateSpeed(x);
|
||||
// Update reporter
|
||||
this.reporter.textContent = `${value}%`;
|
||||
this.reporter.textContent = `${x}%`;
|
||||
}
|
||||
|
||||
private updateSpeed(speed: number) {
|
||||
|
Reference in New Issue
Block a user