Re-implement Math.sign so it works on IE 11 (not supported). Square shaped corners for Flyout

This commit is contained in:
Sam El-Husseini 2018-01-05 17:35:25 -08:00
parent 76ff39605a
commit 50f6b04ed4
2 changed files with 23 additions and 2 deletions

View File

@ -111,6 +111,20 @@ function updateBlocklyShape() {
'l ' + 0 + ',' + (Blockly.BlockSvg as any).CORNER_RADIUS * 2 + 'l ' + 0 + ',' + (Blockly.BlockSvg as any).CORNER_RADIUS * 2 +
'l ' + (Blockly.BlockSvg as any).CORNER_RADIUS + ',' + 0; 'l ' + (Blockly.BlockSvg as any).CORNER_RADIUS + ',' + 0;
/**
* Corner radius of the flyout background.
* @type {number}
* @const
*/
(Blockly as any).Flyout.prototype.CORNER_RADIUS = 0;
/**
* Margin around the edges of the blocks in the flyout.
* @type {number}
* @const
*/
(Blockly as any).Flyout.prototype.MARGIN = 8;
} }
// When require()d from node, bind the global pxt namespace // When require()d from node, bind the global pxt namespace

View File

@ -176,8 +176,15 @@ namespace pxsim {
// let it coast to speed 0 // let it coast to speed 0
if (this.speed && !(this.started || this.speedCmd)) { if (this.speed && !(this.started || this.speedCmd)) {
// decay speed 5% per tick // decay speed 5% per tick
this.speed = Math.round(Math.max(0, Math.abs(this.speed) - 10) * Math.sign(this.speed)); this.speed = Math.round(Math.max(0, Math.abs(this.speed) - 10) * sign(this.speed));
} }
} }
} }
} }
namespace pxsim {
// A re-implementation of Math.sign (since IE11 doesn't support it)
export function sign(num: number) {
return num ? num < 0 ? -1 : 1 : 0;
}
}