Skip to content

Commit

Permalink
Fixes hakib#13 - Use position relative to parent instead of document
Browse files Browse the repository at this point in the history
  • Loading branch information
MattShrider authored and pmq committed Apr 8, 2015
1 parent 3ce8056 commit b4325d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions massautocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ angular.module('MassAutoComplete', [])
'</div>',
link: function (scope, element) {
scope.container = angular.element(element[0].getElementsByClassName('ac-container')[0]);
scope.element = element;
},
controller: ["$scope", function ($scope) {
var that = this;
Expand Down Expand Up @@ -71,12 +72,11 @@ angular.module('MassAutoComplete', [])

function _position_autocomplete() {
var rect = current_element[0].getBoundingClientRect(),
scrollTop = $document[0].body.scrollTop || $document[0].documentElement.scrollTop || $window.pageYOffset,
scrollLeft = $document[0].body.scrollLeft || $document[0].documentElement.scrollLeft || $window.pageXOffset,
parentOffset = angular.element($scope.element[0].offsetParent)[0].getBoundingClientRect(),
container = $scope.container[0];

container.style.top = rect.top + rect.height + scrollTop + 'px';
container.style.left = rect.left + scrollLeft + 'px';
container.style.top = rect.top + rect.height - parentOffset.top + 'px';
container.style.left = rect.left - parentOffset.left + 'px';
container.style.width = rect.width + 'px';
}
var position_autocomplete = debounce(_position_autocomplete, user_options.debounce_position);
Expand Down

0 comments on commit b4325d1

Please sign in to comment.