|
255 | 255 | }
|
256 | 256 |
|
257 | 257 | var container = completion.options.container || ownerDocument.body;
|
| 258 | + var marginBottom = completion.options.marginBottom || 0; |
258 | 259 | var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
259 |
| - var left = pos.left, top = pos.bottom, below = true; |
260 |
| - var offsetLeft = 0, offsetTop = 0; |
| 260 | + var left = pos.left, top = pos.bottom, bottom = pos.top, below = true; |
| 261 | + var offsetLeft = 0, offsetTop = 0, offsetBottom = 0; |
261 | 262 | if (container !== ownerDocument.body) {
|
262 | 263 | // We offset the cursor position because left and top are relative to the offsetParent's top left corner.
|
263 | 264 | var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1;
|
|
266 | 267 | var bodyPosition = ownerDocument.body.getBoundingClientRect();
|
267 | 268 | offsetLeft = (offsetParentPosition.left - bodyPosition.left - offsetParent.scrollLeft);
|
268 | 269 | offsetTop = (offsetParentPosition.top - bodyPosition.top - offsetParent.scrollTop);
|
| 270 | + offsetBottom = (offsetParentPosition.bottom - bodyPosition.bottom); |
269 | 271 | }
|
270 | 272 | hints.style.left = (left - offsetLeft) + "px";
|
271 | 273 | hints.style.top = (top - offsetTop) + "px";
|
|
285 | 287 | var startScroll;
|
286 | 288 | setTimeout(function() { startScroll = cm.getScrollInfo(); });
|
287 | 289 |
|
288 |
| - var overlapY = box.bottom - winH; |
| 290 | + var overlapY = box.bottom + marginBottom - winH; |
289 | 291 | if (overlapY > 0) { // Does not fit below
|
290 | 292 | var height = box.bottom - box.top, spaceAbove = box.top - (pos.bottom - pos.top) - 2
|
291 | 293 | if (winH - box.top < spaceAbove) { // More room at the top
|
292 | 294 | if (height > spaceAbove) hints.style.height = (height = spaceAbove) + "px";
|
293 |
| - hints.style.top = ((top = pos.top - height) + offsetTop) + "px"; |
| 295 | + hints.style.top = "auto"; |
| 296 | + hints.style.bottom = (winH - (bottom - offsetBottom)) + "px"; |
294 | 297 | below = false;
|
295 | 298 | } else {
|
296 | 299 | hints.style.height = (winH - box.top - 2) + "px";
|
|
0 commit comments