Re-implement Math.sign so it works on IE 11 (not supported). Square shaped corners for Flyout
This commit is contained in:
parent
76ff39605a
commit
50f6b04ed4
@ -5,7 +5,7 @@ import { deployCoreAsync, initAsync } from "./deploy";
|
|||||||
import { FieldPorts } from "./field_ports";
|
import { FieldPorts } from "./field_ports";
|
||||||
import { FieldImages } from "./field_images";
|
import { FieldImages } from "./field_images";
|
||||||
|
|
||||||
pxt.editor.initExtensionsAsync = function(opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||||
pxt.debug('loading pxt-ev3 target extensions...')
|
pxt.debug('loading pxt-ev3 target extensions...')
|
||||||
updateBlocklyShape();
|
updateBlocklyShape();
|
||||||
const res: pxt.editor.ExtensionResult = {
|
const res: pxt.editor.ExtensionResult = {
|
||||||
@ -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
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user