Skip to content

Commit

Permalink
Merge pull request #2 from vdtn359/master
Browse files Browse the repository at this point in the history
Scroll active item into view
  • Loading branch information
vdtn359 authored Nov 20, 2018
2 parents a0ad580 + ee30b59 commit cbd28c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mention/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,22 @@
index = (currentIndex === 0) ? this.$dropdown.find('li').length - 1 : --currentIndex;

this.$dropdown.find('li').removeClass('active').eq(index).addClass('active');
this.scrollItemIntoView(index);
},

highlightNextResult: function () {
var currentIndex = this.$dropdown.find('li.active').index(),
index = (currentIndex === this.$dropdown.find('li').length - 1) ? 0 : ++currentIndex;

this.$dropdown.find('li').removeClass('active').eq(index).addClass('active');
this.scrollItemIntoView(index);
},

scrollItemIntoView: function(index) {
var listItems = this.$dropdown.find('li');
this.$dropdown.scrollTop(listItems.eq(index).position().top - listItems.eq(0).position().top - this.$dropdown.height() / 2);
},

select: function (item) {
this.editor.focus();
var selection = this.editor.dom.select('span#autocomplete')[0];
Expand Down
2 changes: 1 addition & 1 deletion mention/plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cbd28c8

Please sign in to comment.