From: Colin <34158322+teroman@users.noreply.github.com> Date: Fri, 10 Aug 2018 07:32:35 +0000 (+0100) Subject: Event handling to use target instead currentTarget (#5575) X-Git-Tag: v2.7.3~1^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3830216420d7f85ed4a037bfb3bc7be1d7e70512;p=thirdparty%2FChart.js.git Event handling to use target instead currentTarget (#5575) If you attach event handlers to a container rather than directly to the canvas then the currentTarget is the container, event.target is the canvas that triggers the event. It's useful to do this if you have many charts or are creating them dynamically. --- diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 844fa1fd5..5cd1d8f6e 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -383,7 +383,7 @@ module.exports = function() { helpers.getRelativePosition = function(evt, chart) { var mouseX, mouseY; var e = evt.originalEvent || evt; - var canvas = evt.currentTarget || evt.srcElement; + var canvas = evt.target || evt.srcElement; var boundingRect = canvas.getBoundingClientRect(); var touches = e.touches;