Skip to content

Commit

Permalink
Build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Humphreys committed Jan 20, 2017
2 parents 37fa6e8 + 62c45c3 commit 7aa1925
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 ZURB, Inc.
Copyright (c) 2017 ZURB, Inc.
Copyright (c) 2014 Jeff Collins
Copyright (c) 2012 Matt York

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tribute",
"description": "Native ES6 @mentions",
"version": "2.2.0",
"version": "2.3.0",
"main": [
"dist/tribute.js",
"dist/tribute.css"
Expand Down
28 changes: 27 additions & 1 deletion dist/tribute.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tribute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/tribute.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tributejs",
"version": "2.2.0",
"version": "2.3.0",
"description": "Native ES6 @mentions",
"main": "dist/tribute.js",
"devDependencies": {
Expand Down
25 changes: 25 additions & 0 deletions src/TributeEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,43 @@ class TributeEvents {
let lis = this.tribute.menu.querySelectorAll('li'),
length = lis.length >>> 0

// get heights
let menuFullHeight = this.getFullHeight(this.tribute.menu),
liHeight = this.getFullHeight(lis[0])

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

for (let i = 0; i < length; i++) {
let li = lis[i]
if (i === this.tribute.menuSelected) {
let offset = liHeight * (i+1)
let scrollTop = this.tribute.menu.scrollTop
let totalScroll = scrollTop + menuFullHeight

if (offset > totalScroll) {
this.tribute.menu.scrollTop += liHeight
} else if (offset < totalScroll) {
this.tribute.menu.scrollTop -= liHeight
}

li.className = this.tribute.current.collection.selectClass
} else {
li.className = ''
}
}
}

getFullHeight(elem, includeMargin) {
let height = elem.getBoundingClientRect().height

if (includeMargin) {
let style = elem.currentStyle || window.getComputedStyle(elem)
return height + parseFloat(style.marginTop) + parseFloat(style.marginBottom)
}

return height
}

}

export default TributeEvents;

0 comments on commit 7aa1925

Please sign in to comment.