]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Improve point.xRange and point.yRange performance (#5062)
authorBoyi C <cby@cby.me>
Mon, 18 Dec 2017 19:24:02 +0000 (03:24 +0800)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Mon, 18 Dec 2017 19:24:02 +0000 (20:24 +0100)
src/elements/element.point.js

index d5116a259c5b8d96c3bf96e0d7e69c1d1fb26e4b..eab5b31d453c018fc57471827925f59aa984f3b4 100644 (file)
@@ -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({