Minor improvement to code that gets active elements

This commit is contained in:
etimberg 2015-11-21 22:44:11 -05:00
parent 2efb974189
commit 0a17edd1ae

View File

@ -420,30 +420,23 @@
this.active = [];
this.tooltipActive = [];
} else {
this.active = function() {
switch (this.options.hover.mode) {
var _this = this;
function getItemsForMode(mode) {
switch (mode) {
case 'single':
return this.getElementAtEvent(e);
return _this.getElementAtEvent(e);
case 'label':
return this.getElementsAtEvent(e);
return _this.getElementsAtEvent(e);
case 'dataset':
return this.getDatasetAtEvent(e);
return _this.getDatasetAtEvent(e);
default:
return e;
}
}.call(this);
this.tooltipActive = function() {
switch (this.options.tooltips.mode) {
case 'single':
return this.getElementAtEvent(e);
case 'label':
return this.getElementsAtEvent(e);
case 'dataset':
return this.getDatasetAtEvent(e);
default:
return e;
}
}.call(this);
}
this.active = getItemsForMode(this.options.hover.mode);
this.tooltipActive = getItemsForMode(this.options.tooltips.mode);
}
// On Hover hook