]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Event handling to use target instead currentTarget (#5575)
authorColin <34158322+teroman@users.noreply.github.com>
Fri, 10 Aug 2018 07:32:35 +0000 (08:32 +0100)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Fri, 10 Aug 2018 07:32:35 +0000 (09:32 +0200)
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

index 844fa1fd51d3d9711d11da584008737cc61f91ee..5cd1d8f6e91c3a47fb1b0a2507e439bceff3c9f9 100644 (file)
@@ -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;