Commit 858eee9e authored by Phil Hughes's avatar Phil Hughes

Correctly scrolls the dropdown up & down with arrow keys

parent b244317a
...@@ -436,15 +436,22 @@ class GitLabDropdown ...@@ -436,15 +436,22 @@ class GitLabDropdown
# Dropdown content scroll area # Dropdown content scroll area
$dropdownContent = $listItem.closest('.dropdown-content') $dropdownContent = $listItem.closest('.dropdown-content')
dropdownContentBottom = $dropdownContent.prop('offsetTop') + $dropdownContent.prop('offsetHeight') dropdownScrollTop = $dropdownContent.prop('scrollTop')
dropdownContentHeight = $dropdownContent.prop('offsetHeight')
dropdownContentTop = $dropdownContent.prop('offsetTop')
dropdownContentBottom = dropdownContentTop + dropdownContentHeight
# Get the offset bottom of the list item # Get the offset bottom of the list item
listItemBottom = $listItem.prop('offsetTop') + $listItem.prop('offsetHeight') listItemHeight = $listItem.prop('offsetHeight')
console.log listItemBottom, dropdownContentBottom listItemTop = $listItem.prop('offsetTop')
listItemBottom = listItemTop + listItemHeight
if listItemBottom > dropdownContentBottom if listItemBottom > dropdownContentBottom + dropdownScrollTop
# Scroll the dropdown content down # Scroll the dropdown content down
$dropdownContent.scrollTop(listItemBottom - dropdownContentBottom) $dropdownContent.scrollTop(listItemBottom - dropdownContentBottom)
else if listItemTop < dropdownContentTop + dropdownScrollTop
# Scroll the dropdown content up
$dropdownContent.scrollTop(listItemTop - dropdownContentTop)
$.fn.glDropdown = (opts) -> $.fn.glDropdown = (opts) ->
return @.each -> return @.each ->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment