From cfca0b24c132837b47d045fe061fe07be9c29152 Mon Sep 17 00:00:00 2001 From: Colin <34158322+teroman@users.noreply.github.com> Date: Fri, 10 Aug 2018 08:32:35 +0100 Subject: [PATCH] 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. --- src/core/core.helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 844fa1fd51d..5cd1d8f6e91 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;