Skip to content

Commit

Permalink
Fix alignment for better visuals.
Browse files Browse the repository at this point in the history
  • Loading branch information
backnol committed Oct 13, 2015
1 parent e22f093 commit 3002e6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions angularjs-datetime-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
DatetimePicker.$inject = ['$compile', '$document', '$controller'];
angular.module('angularjs-datetime-picker').factory('DatetimePicker', DatetimePicker);

var DatetimePickerCtrl = function($compile, $document, dateFilter) {
var DatetimePickerCtrl = function($compile, $document) {
var datetimePickerEl;
var _this = this;
var removeEl = function(el) {
Expand Down Expand Up @@ -64,13 +64,19 @@

//show datetimePicker below triggerEl
var bcr = triggerEl.getBoundingClientRect();
datetimePickerEl.style.position='absolute';
datetimePickerEl.style.left= (bcr.left + window.scrollX) + 'px';


options.scope.$apply();

var datePickerElBcr = datetimePickerEl.getBoundingClientRect();

datetimePickerEl.style.position='absolute';
if(bcr.width > datePickerElBcr.width){
datetimePickerEl.style.left= (bcr.left + bcr.width - datePickerElBcr.width + window.scrollX) + 'px';
} else {
datetimePickerEl.style.left= (bcr.left + window.scrollX) + 'px';
}

if (bcr.top < 300 || window.innerHeight - bcr.bottom > 300) {
datetimePickerEl.style.top = (bcr.bottom + window.scrollY) + 'px';
} else {
Expand Down Expand Up @@ -148,7 +154,7 @@

daysOfWeek.push({
fullName: day,
firstLetter: day.substr(0, 2)
firstLetter: day.substr(0, 1)
});
}
firstDayOfWeek = $locale.DATETIME_FORMATS.FIRSTDAYOFWEEK || 0;
Expand Down
2 changes: 1 addition & 1 deletion angularjs-datetime-picker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3002e6d

Please sign in to comment.