Fix bug when options.data.length == 2.

Closes #19
This commit is contained in:
Olly Smith 2012-02-29 08:10:48 +00:00
parent 819f40b3d4
commit b3b8377c53
3 changed files with 14 additions and 8 deletions

View File

@ -223,10 +223,10 @@ class Morris.Line
hideHover() hideHover()
updateHilight = (x) => updateHilight = (x) =>
x -= @el.offset().left x -= @el.offset().left
for i in [hoverMargins.length..1] for hoverIndex in [hoverMargins.length..0]
if hoverMargins[i - 1] > x if hoverIndex == 0 || hoverMargins[hoverIndex - 1] > x
hilight hoverIndex
break break
hilight i
@el.mousemove (evt) => @el.mousemove (evt) =>
updateHilight evt.pageX updateHilight evt.pageX
touchHandler = (evt) => touchHandler = (evt) =>

View File

@ -230,12 +230,18 @@
if (index === null) return hideHover(); if (index === null) return hideHover();
}; };
updateHilight = function(x) { updateHilight = function(x) {
var i, _ref9; var hoverIndex, _ref9, _results;
x -= _this.el.offset().left; x -= _this.el.offset().left;
for (i = _ref9 = hoverMargins.length; _ref9 <= 1 ? i <= 1 : i >= 1; _ref9 <= 1 ? i++ : i--) { _results = [];
if (hoverMargins[i - 1] > x) break; for (hoverIndex = _ref9 = hoverMargins.length; _ref9 <= 0 ? hoverIndex <= 0 : hoverIndex >= 0; _ref9 <= 0 ? hoverIndex++ : hoverIndex--) {
if (hoverIndex === 0 || hoverMargins[hoverIndex - 1] > x) {
hilight(hoverIndex);
break;
} else {
_results.push(void 0);
}
} }
return hilight(i); return _results;
}; };
this.el.mousemove(function(evt) { this.el.mousemove(function(evt) {
return updateHilight(evt.pageX); return updateHilight(evt.pageX);

2
morris.min.js vendored

File diff suppressed because one or more lines are too long