fix(popup): if popup is taller than the window, shrink the popup body and make it scrollable. Closes #1679

This commit is contained in:
Perry Govier
2014-06-27 11:27:06 -05:00
parent f4043e673c
commit 3e6ce1831b
4 changed files with 38 additions and 0 deletions

View File

@@ -317,6 +317,17 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $docume
//if hidden while waiting for raf, don't show
if (!self.isShown) return;
//if the popup is taller than the window, make the popup body scrollable
if(self.element[0].offsetHeight > window.innerHeight - 20){
self.element[0].style.height = window.innerHeight - 20+'px';
popupBody = self.element[0].querySelectorAll('.popup-body');
popupHead = self.element[0].querySelectorAll('.popup-head');
popupButtons = self.element[0].querySelectorAll('.popup-buttons');
self.element.addClass('popup-tall');
newHeight = window.innerHeight - popupHead[0].offsetHeight - popupButtons[0].offsetHeight -20;
popupBody[0].style.height = newHeight + 'px';
};
self.element.removeClass('popup-hidden');
self.element.addClass('popup-showing active');
ionic.DomUtil.centerElementByMarginTwice(self.element[0]);