Skip to content

Commit

Permalink
Merge pull request adobe#1357 from adobe/randy/code-hints-scroll
Browse files Browse the repository at this point in the history
Good catch. Merging...
  • Loading branch information
tvoliter committed Aug 9, 2012
2 parents 375fe35 + 77e45c4 commit 5c24dd1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/editor/CodeHintManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ define(function (require, exports, module) {

this.opened = false;
this.selectedIndex = -1;
this.itemsPerPage = -1;
this.editor = null;

this.$hintMenu = $("<li class='dropdown codehint-menu'></li>");
Expand Down Expand Up @@ -323,27 +322,21 @@ define(function (require, exports, module) {
* @return {number}
*/
CodeHintList.prototype.getItemsPerPage = function () {
if (this.itemsPerPage > 0) {
return this.itemsPerPage;
}

// default
this.itemsPerPage = 1;

var $items = this.$hintMenu.find("li"),
var itemsPerPage = 1,
$items = this.$hintMenu.find("li"),
$view = this.$hintMenu.find("ul.dropdown-menu"),
itemHeight;

if ($items.length !== 0) {
itemHeight = $($items[0]).height();
if (itemHeight) {
// round down to integer value
this.itemsPerPage = Math.floor($view.height() / itemHeight);
this.itemsPerPage = Math.max(1, Math.min(this.itemsPerPage, $items.length));
itemsPerPage = Math.floor($view.height() / itemHeight);
itemsPerPage = Math.max(1, Math.min(itemsPerPage, $items.length));
}
}

return this.itemsPerPage;
return itemsPerPage;
};

// HintList is a singleton for now. Todo: Figure out broader strategy for hint list across editors
Expand Down

0 comments on commit 5c24dd1

Please sign in to comment.