From: Boyi C Date: Mon, 18 Dec 2017 19:24:02 +0000 (+0800) Subject: Improve point.xRange and point.yRange performance (#5062) X-Git-Tag: v2.7.2~1^2~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce1fc28b743d518add5c89653108a287f6aa911d;p=thirdparty%2FChart.js.git Improve point.xRange and point.yRange performance (#5062) --- diff --git a/src/elements/element.point.js b/src/elements/element.point.js index d5116a259..eab5b31d4 100644 --- a/src/elements/element.point.js +++ b/src/elements/element.point.js @@ -24,12 +24,12 @@ defaults._set('global', { function xRange(mouseX) { var vm = this._view; - return vm ? (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hitRadius, 2)) : false; + return vm ? (Math.abs(mouseX - vm.x) < vm.radius + vm.hitRadius) : false; } function yRange(mouseY) { var vm = this._view; - return vm ? (Math.pow(mouseY - vm.y, 2) < Math.pow(vm.radius + vm.hitRadius, 2)) : false; + return vm ? (Math.abs(mouseY - vm.y) < vm.radius + vm.hitRadius) : false; } module.exports = Element.extend({