From 84bc5146e1a75e42674927d520777323f33c7e7e Mon Sep 17 00:00:00 2001 From: samreid Date: Wed, 4 Oct 2017 15:49:01 -0600 Subject: [PATCH] Added Util.sign, see https://github.com/phetsims/circuit-construction-kit-dc/issues/163 --- js/Util.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/js/Util.js b/js/Util.js index 90642ca..0b191ab 100644 --- a/js/Util.js +++ b/js/Util.js @@ -599,6 +599,15 @@ define( function( require ) { return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y); }, + /** + * Polyfill for Math.sign from MDN, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign + * We cannot use Math.sign because it is not supported on IE + * @param {number} x + * @returns {number} + */ + sign: function( x ) { + return ((x > 0) - (x < 0)) || +x; + }, /** * Function that returns the hyperbolic cosine of a number