diff --git a/daterangepicker.js b/daterangepicker.js index a6ea6c8b..e2a3128e 100644 --- a/daterangepicker.js +++ b/daterangepicker.js @@ -1023,7 +1023,9 @@ move: function() { var parentOffset = { top: 0, left: 0 }, - containerTop; + containerTop, + drops = this.drops; + var parentRightEdge = $(window).width(); if (!this.parentEl.is('body')) { parentOffset = { @@ -1033,10 +1035,21 @@ parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left; } - if (this.drops == 'up') + switch (drops) { + case 'auto': + containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top; + if (containerTop + this.container.outerHeight() >= this.parentEl[0].scrollHeight) { + containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top; + drops = 'up'; + } + break; + case 'up': containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top; - else + break; + default: containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top; + break; + } // Force the container to it's actual width this.container.css({ @@ -1046,7 +1059,7 @@ }); var containerWidth = this.container.outerWidth(); - this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up'); + this.container.toggleClass('drop-up', drops == 'up'); if (this.opens == 'left') { var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth(); diff --git a/website/index.html b/website/index.html index a1002644..fb11a40f 100644 --- a/website/index.html +++ b/website/index.html @@ -263,7 +263,7 @@

Predefined Date Ranges

}, cb); cb(start, end); - + }); @@ -282,7 +282,7 @@

Input Initially Empty

- +
- +