From 0146ba707cc0db013afe1c7ef6f8c82cda057b46 Mon Sep 17 00:00:00 2001 From: Kefan Xie Date: Sun, 4 Mar 2012 18:03:56 -0500 Subject: [PATCH] Added hideHover option to hide hover when mousing out --- morris.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/morris.js b/morris.js index e123102..1d21745 100644 --- a/morris.js +++ b/morris.js @@ -45,7 +45,8 @@ hoverLabelColor: '#444', hoverFontSize: 12, smooth: true, - parseTime: true + parseTime: true, + hideHover: false }; Line.prototype.precalc = function() { @@ -263,6 +264,11 @@ this.el.mousemove(function(evt) { return updateHilight(evt.pageX); }); + if (_this.options.hideHover) { + this.el.mouseout(function(evt) { + return hilight(null); + }); + } touchHandler = function(evt) { var touch; touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0]; @@ -272,7 +278,11 @@ this.el.bind('touchstart', touchHandler); this.el.bind('touchmove', touchHandler); this.el.bind('touchend', touchHandler); - return hilight(0); + if (_this.options.hideHover) { + return hilight(null); + } else { + return hilight(0); + } }; Line.prototype.createPath = function(coords, top, left, bottom, right) {