Introduction
Introduction Statistics Contact Development Disclaimer Help
datalist: use draft getClientRects, works (better) on ff, ie, webkit - jscancer…
git clone git://git.codemadness.org/jscancer
Log
Files
Refs
README
LICENSE
---
commit 887ccc8411a5bb8673657133b894b689aab82a81
parent 4b633a3a0d2361d17515a108f97b04ca829ec732
Author: Hiltjo Posthuma <[email protected]>
Date: Thu, 1 Jun 2017 19:54:40 +0200
datalist: use draft getClientRects, works (better) on ff, ie, webkit
Diffstat:
M datalist/datalist.js | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/datalist/datalist.js b/datalist/datalist.js
@@ -59,20 +59,12 @@ function datalist_init(input) {
};
var datalist_render = function(m) {
var dd = dropdown.cloneNode(false);
- var left = 0, top = 0;
- for (var c = input; c; c = c.offsetParent) {
- left += c.offsetLeft;
- top += c.offsetTop;
- if (c.style.position == "fixed") {
- left += window.pageXOffset;
- top += window.pageYOffset;
- break;
- }
+ var r = input.getClientRects() || [];
+ if (r.length) {
+ dd.style.left = String(r[0].left + window.pageXOffset)…
+ dd.style.top = String(r[0].top + input.offsetHeight + …
}
- dd.style.left = String(left) + "px";
- dd.style.top = String(top + input.offsetHeight) + "px";
dd.style.minWidth = String(input.clientWidth) + "px";
-
for (var i = 0; i < m.length; i++)
dd.appendChild(m[i].el);
dropdown.parentNode.replaceChild(dd, dropdown)
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.