commit 4b633a3a0d2361d17515a108f97b04ca829ec732 parent 2f59a2607931adbfda644713662b2eace4c3e220 Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Thu, 1 Jun 2017 19:54:17 +0200 datepicker: use draft getClientRects, works (better) on ff, ie, webkit Diffstat:
| M | datepicker/datepicker.js | | | 15 | ++++----------- |
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/datepicker/datepicker.js b/datepicker/datepicker.js @@ -77,18 +77,11 @@ function datepicker_init(input) { table.hidden = false; table.style.display = "table"; table.style.position = "absolute"; - 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) { + table.style.left = String(r[0].left + window.pageXOffset) + "px"; + table.style.top = String(r[0].top + input.offsetHeight + window.pageYOffset) + "px"; } - table.style.left = String(left) + "px"; - table.style.top = String(top + input.offsetHeight) + "px"; // scroll if outside window. input.scrollIntoView(); };