diff --git a/daterangepicker.js b/daterangepicker.js index c6227f4d..7eae86ef 100644 --- a/daterangepicker.js +++ b/daterangepicker.js @@ -1041,6 +1041,7 @@ // Create a click proxy that is private to this instance of datepicker, for unbinding this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this); + // Bind global datepicker mousedown for hiding and $(document) .on('mousedown.daterangepicker', this._outsideClickProxy) @@ -1051,6 +1052,9 @@ // and also close when focus changes to outside the picker (eg. tabbing between controls) .on('focusin.daterangepicker', this._outsideClickProxy); + // Reposition the picker if the window is resized while it's open + $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this)); + this.oldStartDate = this.startDate.clone(); this.oldEndDate = this.endDate.clone(); @@ -1078,6 +1082,7 @@ this.updateElement(); $(document).off('.daterangepicker'); + $(window).off('.daterangepicker'); this.container.hide(); this.element.trigger('hide.daterangepicker', this); this.isShowing = false;