Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions massautocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ angular.module('MassAutoComplete', [])

// Position ac container given a target element
config.position_autocomplete = function(container, target) {
var rect = target[0].getBoundingClientRect(),
scrollTop = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset,
scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft || window.pageXOffset;
var rect = target[0].getBoundingClientRect();

container[0].style.top = rect.top + rect.height + scrollTop + 'px';
container[0].style.left = rect.left + scrollLeft + 'px';
container[0].style.left = 0;
container[0].style.top = rect.height + 'px';
container[0].style.width = rect.width + 'px';
};

Expand Down Expand Up @@ -80,7 +78,7 @@ angular.module('MassAutoComplete', [])
scope.container = angular.element(element[0].getElementsByClassName('ac-container')[0]);
},

controller: ['$scope', function($scope) {
controller: ['$scope', '$element', function($scope, $element) {
var that = this;

var bound_events = {};
Expand Down Expand Up @@ -427,6 +425,12 @@ angular.module('MassAutoComplete', [])
that.detach();
$scope.container.remove();
});

// Make element positionned if not already
if (['fixed', 'absolute', 'sticky', 'relative'].indexOf($element.css('position')) === -1) {
$element.css('position', 'relative');
}

}]
};
}])
Expand Down
2 changes: 1 addition & 1 deletion massautocomplete.min.js

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