From a6dfb9e33b2b21100d1699320786504c5fbd6fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20D=C3=B6rr?= Date: Thu, 21 Jan 2016 14:39:15 +0100 Subject: [PATCH 1/2] Added option for setting offset for autocomplete list --- src/jquery.autocomplete.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 91afcab5..b80bc06a 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -122,7 +122,8 @@ showNoSuggestionNotice: false, noSuggestionNotice: 'No results', orientation: 'bottom', - forceFixPosition: false + forceFixPosition: false, + positionOffset: [0, 0] }; function _lookupFilter(suggestion, originalQuery, queryLowerCase) { @@ -308,7 +309,8 @@ containerHeight = $container.outerHeight(), height = that.el.outerHeight(), offset = that.el.offset(), - styles = { 'top': offset.top, 'left': offset.left }; + styles = { 'top': offset.top + that.options.positionOffset[1], + 'left': offset.left + that.options.positionOffset[0] }; if (orientation === 'auto') { var viewPortHeight = $(window).height(), From 928c1a3a7c4576d3de225fbec95a0103c214505e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20D=C3=B6rr?= Date: Thu, 21 Jan 2016 14:43:47 +0100 Subject: [PATCH 2/2] Updated readme --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 905cce86..7105a50b 100644 --- a/readme.md +++ b/readme.md @@ -55,6 +55,7 @@ The standard jquery.autocomplete.js file is around 13KB when minified. * `groupBy`: property name of the suggestion `data` object, by which results should be grouped. * `maxHeight`: Maximum height of the suggestions container in pixels. Default: `300`. * `width`: Suggestions container width in pixels, e.g.: 300, `flex` for max suggestion size and `auto` takes input field width. Default: `auto` +* `positionOffset`: Offset of suggestions container in pixels. Default: `[0, 0]`. * `zIndex`: 'z-index' for suggestions container. Default: `9999`. * `appendTo`: container where suggestions will be appended. Default value `document.body`. Can be jQuery object, selector or HTML element. Make sure to set `position: absolute` or `position: relative` for that element. * `forceFixPosition`: Default: `false`. Suggestions are automatically positioned when their container is appended to body (look at `appendTo` option), in other cases suggestions are rendered but no positioning is applied.