Skip to content

Commit eda3201

Browse files
author
SimonSteinberger
committed
Included pull Pixabay#6 and added offsetLeft/offsetTop as optional parameter for suggestions container.
1 parent 478e4dd commit eda3201

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

auto-complete.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
JavaScript autoComplete v1.0.3
2+
JavaScript autoComplete v1.0.4
33
Copyright (c) 2014 Simon Steinberger / Pixabay
44
GitHub: https://github.com/Pixabay/JavaScript-autoComplete
55
License: http://www.opensource.org/licenses/mit-license.php
@@ -33,6 +33,8 @@ var autoComplete = (function(){
3333
source: 0,
3434
minChars: 3,
3535
delay: 150,
36+
offsetLeft: 0,
37+
offsetTop: 1,
3638
cache: 1,
3739
menuClass: '',
3840
renderItem: function (item, search){
@@ -61,9 +63,9 @@ var autoComplete = (function(){
6163

6264
that.updateSC = function(resize, next){
6365
var rect = that.getBoundingClientRect();
64-
that.sc.style.left = rect.left + (window.pageXOffset || document.documentElement.scrollLeft) + 'px';
65-
that.sc.style.top = rect.bottom + (window.pageYOffset || document.documentElement.scrollTop) + 1 + 'px';
66-
that.sc.style.width = rect.right - rect.left + 'px'; // outerWidth
66+
that.sc.style.left = Math.round(rect.left + (window.pageXOffset || document.documentElement.scrollLeft) + o.offsetLeft) + 'px';
67+
that.sc.style.top = Math.round(rect.bottom + (window.pageYOffset || document.documentElement.scrollTop) + o.offsetTop) + 'px';
68+
that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth
6769
if (!resize) {
6870
that.sc.style.display = 'block';
6971
if (!that.sc.maxHeight) { that.sc.maxHeight = parseInt((window.getComputedStyle ? getComputedStyle(that.sc, null) : that.sc.currentStyle).maxHeight); }

auto-complete.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "javascript-auto-complete",
33
"description": "An extremely lightweight vanilla JavaScript completion suggester.",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"homepage": "https://github.com/Pixabay/JavaScript-autoComplete",
66
"authors": [{
77
"name": "Simon Steinberger",

demo.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ <h3>Settings</h3>
108108
</td></tr>
109109
<tr><td>minChars</td><td>3</td><td>Minimum number of characters (>=1) a user must type before a search is performed.</td></tr>
110110
<tr><td>delay</td><td>150</td><td>The delay in milliseconds between when a keystroke occurs and when a search is performed. A zero-delay is more responsive, but can produce a lot of load.</td></tr>
111+
<tr><td>offsetLeft</td><td><i>0</i></td><td>Optional left offset of the suggestions container.</td></tr>
112+
<tr><td>offsetTop</td><td><i>1</i></td><td>Optional top offset of the suggestions container.</td></tr>
111113
<tr><td>cache</td><td><i>true</i></td><td>Determines if performed searches should be cached.</td></tr>
112114
<tr>
113115
<td>menuClass</td><td><i>''</i></td>

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ https://goodies.pixabay.com/javascript/auto-complete/demo.html
2222

2323
## Changelog
2424

25+
### Version 1.0.4 - 2016/02/10
26+
27+
* Included pull #6 and added offsetLeft/offsetTop as optional parameter for suggestions container.
28+
29+
2530
### Version 1.0.3 - 2015/11/02
2631

2732
* Fixed #2: Unspecified error on IE 10.

0 commit comments

Comments
 (0)