Fix compiled code using symbols

This commit is contained in:
Niklas von Hertzen 2017-12-12 22:18:15 +08:00
parent f50da9718f
commit 7bb4a6f08f

View File

@ -339,19 +339,21 @@ const findCorner = (bounds: Bounds, x: number, y: number, closest: boolean): Poi
{x: bounds.width, y: bounds.height} {x: bounds.width, y: bounds.height}
]; ];
let optimumDistance = closest ? Infinity : -Infinity;
let optimumCorner = null;
for (let corner of corners) {
const d = distance(x - corner.x, y - corner.y);
if (closest ? d < optimumDistance : d > optimumDistance) {
optimumDistance = d;
optimumCorner = corner;
}
}
// $FlowFixMe // $FlowFixMe
return optimumCorner; return corners.reduce((stat, corner) => {
const d = distance(x - corner.x, y - corner.y);
if (closest ? d < stat.optimumDistance : d > stat.optimumDistance) {
return {
optimumCorner: corner,
optimumDistance: d
};
}
return stat;
}, {
optimumDistance: closest ? Infinity : -Infinity,
optimumCorner: null
}).optimumCorner;
}; };
const calculateRadius = ( const calculateRadius = (