Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
fix(macAutocomplete): Fixed dropdown placement issues
Browse files Browse the repository at this point in the history
Related to #11
  • Loading branch information
adrianlee44 committed Jan 27, 2015
1 parent 999e914 commit 725995c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/directives/autocomplete.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ angular.module("Mac").directive "macAutocomplete", [

isMenuAppended = true

# Hide the element from view when calculating offset
menuEl[0].style.visibility = 'hidden'

if inside
return $animate.enter(menuEl, undefined, element)
else
Expand Down Expand Up @@ -219,12 +222,8 @@ angular.module("Mac").directive "macAutocomplete", [
Calculate the style include position and width for menu
###
positionMenu = ->
parentElement = if inside then element[0] else document.body
parentStyles = window.getComputedStyle parentElement

offset = element.offset()
offset.left -= parseInt parentStyles.marginLeft
offset.top += element.outerHeight() - parseInt parentStyles.marginTop
offset.top += element.outerHeight()
offset.minWidth = element.outerWidth()

# Add 'px' to left and top
Expand All @@ -234,6 +233,9 @@ angular.module("Mac").directive "macAutocomplete", [

menuEl[0].style[key] = value

# Show dropdown when positioned correctly
menuEl[0].style.visibility = 'visible'

###
@function
@name updateItem
Expand Down

0 comments on commit 725995c

Please sign in to comment.