Skip to content

Commit

Permalink
fix(modal): Remove modal flicker, closes #1150
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Bradley committed May 2, 2014
1 parent ae3ae34 commit d2ebed8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion js/angular/service/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla
var modalEl = angular.element(self.modalEl);

self.el.classList.remove('hide');
$document[0].body.classList.add('modal-open');
$timeout(function(){
$document[0].body.classList.add('modal-open');
}, 400)


if(!self.el.parentElement) {
modalEl.addClass(self.animation);
Expand Down
1 change: 1 addition & 0 deletions test/html/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h1 class="title">Modal</h1>
<div class="modal" ng-controller="ModalCtrl">
<ion-header-bar>
<h1 class="title">New Contact</h1>
<button class="button button-positive" ng-click="hideModal()">Close</button>
</ion-header-bar>
<ion-content>
<div class="padding">
Expand Down
4 changes: 3 additions & 1 deletion test/unit/angular/service/modal.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('Ionic Modal', function() {
it('show & remove should add .model-open to body', inject(function() {
var instance = modal.fromTemplate('<div class="modal">hi</div>');
instance.show();
timeout.flush();
expect(angular.element(document.body).hasClass('modal-open')).toBe(true);
instance.remove();
timeout.flush();
Expand All @@ -69,6 +70,7 @@ describe('Ionic Modal', function() {
it('show & hide should add .model-open body', inject(function() {
var instance = modal.fromTemplate('<div class="modal">hi</div>');
instance.show();
timeout.flush();
expect(angular.element(document.body).hasClass('modal-open')).toBe(true);
instance.hide();
timeout.flush();
Expand Down Expand Up @@ -130,7 +132,7 @@ describe('Ionic Modal', function() {
instance.$el.triggerHandler('click');
expect(instance.hide).toHaveBeenCalled();
});

it('should remove click listener on hide', function() {
var template = '<div class="modal"></div>';
var instance = modal.fromTemplate(template);
Expand Down

0 comments on commit d2ebed8

Please sign in to comment.