From 4afcfca6acad61a1a63461705d1127a20a82c2d4 Mon Sep 17 00:00:00 2001 From: Dan Grossman Date: Sat, 17 Oct 2015 10:47:14 -0400 Subject: [PATCH] Move picker when window resized --- daterangepicker.js | 5 +++++ 1 file changed, 5 insertions(+) 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;