From 56171a268f1b1ffc66c1fcf9ea806c68e58b60ff Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 27 Feb 2015 09:20:28 -0700 Subject: [PATCH] fix(popover): only pop upwards if there's room above Closes #3047. Closes #3074. --- js/angular/service/popover.js | 5 +++-- test/html/popover.html | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/angular/service/popover.js b/js/angular/service/popover.js index 8953a34601b..d7a365cb28d 100644 --- a/js/angular/service/popover.js +++ b/js/angular/service/popover.js @@ -109,8 +109,9 @@ function($ionicModal, $ionicPosition, $document, $window) { } // If the popover when popped down stretches past bottom of screen, - // make it pop up - if (buttonOffset.top + buttonOffset.height + popoverHeight > bodyHeight) { + // make it pop up if there's room above + if (buttonOffset.top + buttonOffset.height + popoverHeight > bodyHeight && + buttonOffset.top - popoverHeight > 0) { popoverCSS.top = buttonOffset.top - popoverHeight; popoverEle.addClass('popover-bottom'); } else { diff --git a/test/html/popover.html b/test/html/popover.html index d8af7f26f73..8470ea1ddbf 100644 --- a/test/html/popover.html +++ b/test/html/popover.html @@ -106,6 +106,8 @@

Popover Header

angular.module('ionicApp', ['ionic']) .controller('AppCtrl', function($scope, $ionicPopover) { + $scope.popover = $ionicPopover.fromTemplate('
hello, popover
'); + $scope.popover2 = $ionicPopover.fromTemplate('
hello, popover2
'); $scope.openPopover = function($event) { $scope.popover.show($event);