Skip to content

Commit

Permalink
Fix hover state so that it highlights only the item targeted.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Humphreys committed Oct 11, 2016
1 parent 2a4f61b commit b805f91
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
npm-debug.log
9 changes: 8 additions & 1 deletion dist/tribute.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/Tribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ class Tribute {
items.forEach((item, index) => {
let li = this.range.getDocument().createElement('li')
li.setAttribute('data-index', index)
li.addEventListener('mouseenter', (e) => {
let li = e.target;
let index = li.getAttribute('data-index');
this.events.setActiveLi(index);
});
if (this.menuSelected === index) {
li.className = this.current.collection.selectClass
}
Expand Down
2 changes: 2 additions & 0 deletions src/TributeEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class TributeEvents {
let lis = this.tribute.menu.querySelectorAll('li'),
length = lis.length >>> 0

if (index) this.tribute.menuSelected = index;

for (let i = 0; i < length; i++) {
let li = lis[i]
if (i === this.tribute.menuSelected) {
Expand Down

0 comments on commit b805f91

Please sign in to comment.