Skip to content

Commit

Permalink
fix(popover): only pop upwards if there's room above
Browse files Browse the repository at this point in the history
Closes #3047. Closes #3074.
  • Loading branch information
ajoslin committed Feb 27, 2015
1 parent 3d12853 commit 56171a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/angular/service/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions test/html/popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ <h1 class="title">Popover Header</h1>
angular.module('ionicApp', ['ionic'])

.controller('AppCtrl', function($scope, $ionicPopover) {
$scope.popover = $ionicPopover.fromTemplate('<ion-popover-view><div>hello, popover</div></ion-popover-view>');
$scope.popover2 = $ionicPopover.fromTemplate('<ion-popover-view><div>hello, popover2</div></ion-popover-view>');

$scope.openPopover = function($event) {
$scope.popover.show($event);
Expand Down

0 comments on commit 56171a2

Please sign in to comment.