Ensure leave is called when leaving a MouseZone

Fixes #975
This commit is contained in:
Daniel Imms
2017-09-11 11:12:51 -07:00
parent 948eedba89
commit 2114bc4837
+7 -5
View File
@@ -83,10 +83,14 @@ export class MouseZoneManager implements IMouseZoneManager {
return; return;
} }
// Fire the hover end callback if a zone was being hovered // Fire the hover end callback and cancel any existing timer if a new zone
// is being hovered
if (this._currentZone) { if (this._currentZone) {
this._currentZone.leaveCallback(); this._currentZone.leaveCallback();
this._currentZone = null; this._currentZone = null;
if (this._tooltipTimeout) {
clearTimeout(this._tooltipTimeout);
}
} }
// Exit if there is not zone // Exit if there is not zone
@@ -100,14 +104,12 @@ export class MouseZoneManager implements IMouseZoneManager {
zone.hoverCallback(e); zone.hoverCallback(e);
} }
// Restart the timeout // Restart the tooltip timeout
if (this._tooltipTimeout) {
clearTimeout(this._tooltipTimeout);
}
this._tooltipTimeout = <number><any>setTimeout(() => this._onTooltip(e), HOVER_DURATION); this._tooltipTimeout = <number><any>setTimeout(() => this._onTooltip(e), HOVER_DURATION);
} }
private _onTooltip(e: MouseEvent): void { private _onTooltip(e: MouseEvent): void {
this._tooltipTimeout = null;
const zone = this._findZoneEventAt(e); const zone = this._findZoneEventAt(e);
if (zone && zone.tooltipCallback) { if (zone && zone.tooltipCallback) {
zone.tooltipCallback(e); zone.tooltipCallback(e);