Skip to content

Commit

Permalink
Fix mouse intereference when performing keyboard navigation in the re…
Browse files Browse the repository at this point in the history
…sults menu
  • Loading branch information
vcekov committed Jan 15, 2016
1 parent 3377178 commit a0e08a8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
26 changes: 20 additions & 6 deletions dist/js/jquery.atwho.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! jquery.atwho - v1.4.0 %>
* Copyright (c) 2015 chord.luo <[email protected]>;
* Copyright (c) 2016 chord.luo <[email protected]>;
* homepage: http://ichord.github.com/At.js
* Licensed MIT
*/
Expand Down Expand Up @@ -812,12 +812,26 @@ View = (function() {
};

View.prototype.bindEvent = function() {
var $menu;
var $menu, lastCoordX, lastCoordY;
$menu = this.$el.find('ul');
return $menu.on('mouseenter.atwho-view', 'li', function(e) {
$menu.find('.cur').removeClass('cur');
return $(e.currentTarget).addClass('cur');
}).on('click.atwho-view', 'li', (function(_this) {
lastCoordX = 0;
lastCoordY = 0;
return $menu.on('mousemove.atwho-view', 'li', (function(_this) {
return function(e) {
var $cur;
if (lastCoordX === e.clientX && lastCoordY === e.clientY) {
return;
}
lastCoordX = e.clientX;
lastCoordY = e.clientY;
$cur = $(e.currentTarget);
if ($cur.hasClass('cur')) {
return;
}
$menu.find('.cur').removeClass('cur');
return $cur.addClass('cur');
};
})(this)).on('click.atwho-view', 'li', (function(_this) {
return function(e) {
$menu.find('.cur').removeClass('cur');
$(e.currentTarget).addClass('cur');
Expand Down
Loading

0 comments on commit a0e08a8

Please sign in to comment.