diff --git a/lib/knockout.autocomplete.js b/lib/knockout.autocomplete.js index c79a1e3..72ab0c8 100644 --- a/lib/knockout.autocomplete.js +++ b/lib/knockout.autocomplete.js @@ -582,6 +582,8 @@ var left = offset.left; var right = left + dropdownWidth; var bottom = null; + var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; + var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0; if ((mobileSafari && spaceBelow < 600) || (dropdownHeight > spaceBelow)) { // Place above @@ -591,16 +593,16 @@ if (right > $window.width()) { left = Math.max($window.width() - dropdownWidth, 0); } else { - left -= document.body.scrollLeft; + left -= scrollLeft; } // Constrain the menu to the viewport - if (top < document.body.scrollTop) { + if (top < scrollTop) { // constrained by bottom - top = document.body.scrollTop; + top = scrollTop; bottom = $window.height() - (offset.top - 5); } else { - top -= document.body.scrollTop; + top -= scrollTop; } if (top + dropdownHeight > windowHeight) {