Skip to content

Commit

Permalink
This position-altering code is not correct on layouts where the body …
Browse files Browse the repository at this point in the history
…has a margin, and I'm not sure how to correct it without breaking the site of whoever contributed this code. I'm disabling it for the default case of a picker attached to the body of the page, which will make te position correct on those pages regardless of body margins.
  • Loading branch information
dangrossman committed Jan 16, 2014
1 parent 3d4e0fe commit 89be8ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ $('input[name="daterange"]').daterangepicker(

`locale`: (object) Allows you to provide localized strings for buttons and labels, and the first day of week for the calendars

`parentEl`: (string or jQuery object) The document object the picker will be appended to at creation; defaults to 'body'

`singleDatePicker`: (boolean) Show only a single calendar to choose one date, instead of a range picker with two calendars; the start and end dates provided to your callback will be the same single date chosen

## Functions
Expand Down
12 changes: 8 additions & 4 deletions daterangepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,14 @@
},

move: function () {
var parentOffset = {
top: this.parentEl.offset().top - (this.parentEl.is('body') ? 0 : this.parentEl.scrollTop()),
left: this.parentEl.offset().left - (this.parentEl.is('body') ? 0 : this.parentEl.scrollLeft())
};
var parentOffset = { top: 0, left: 0 };
if (!this.parentEl.is('body')) {
parentOffset = {
top: this.parentEl.offset().top - this.parentEl.scrollTop(),
left: this.parentEl.offset().left - this.parentEl.scrollLeft()
};
}

if (this.opens == 'left') {
this.container.css({
top: this.element.offset().top + this.element.outerHeight() - parentOffset.top,
Expand Down

0 comments on commit 89be8ab

Please sign in to comment.