Skip to content

Commit

Permalink
Event handling to use target instead currentTarget (chartjs#5575)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
teroman authored and simonbrunel committed Aug 10, 2018
1 parent 9bd905d commit cfca0b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/core.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cfca0b2

Please sign in to comment.