]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix onHover event not being triggered (#4297)
authorRicardo Costa <ricardocosta89@users.noreply.github.com>
Sun, 28 May 2017 21:23:20 +0000 (22:23 +0100)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 28 May 2017 21:23:20 +0000 (17:23 -0400)
Fix onHover event not being triggered

The core controller was looking at the wrong object (options.hover) to
find the function to be called on hover. The function is provided on the
top level options object (options.onHover).

By using the helper function, there's no need to verify if the callback
is defined, as the helper already does that.

Fixes #4296

src/core/core.controller.js

index 71eb3bb628c17beb68a88a6bbb1646a277f6c7c5..f8c471f3d28a6df497fba5c9f85f9b846d0ee2f0 100644 (file)
@@ -808,11 +808,9 @@ module.exports = function(Chart) {
                                me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions);
                        }
 
-                       // On Hover hook
-                       if (hoverOptions.onHover) {
-                               // Need to call with native event here to not break backwards compatibility
-                               hoverOptions.onHover.call(me, e.native, me.active);
-                       }
+                       // Invoke onHover hook
+                       // Need to call with native event here to not break backwards compatibility
+                       helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me);
 
                        if (e.type === 'mouseup' || e.type === 'click') {
                                if (options.onClick) {