Skip to content

Commit d2ebed8

Browse files
author
Adam Bradley
committed
fix(modal): Remove modal flicker, closes #1150
1 parent ae3ae34 commit d2ebed8

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

js/angular/service/modal.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ function($rootScope, $document, $compile, $timeout, $ionicPlatform, $ionicTempla
9494
var modalEl = angular.element(self.modalEl);
9595

9696
self.el.classList.remove('hide');
97-
$document[0].body.classList.add('modal-open');
97+
$timeout(function(){
98+
$document[0].body.classList.add('modal-open');
99+
}, 400)
100+
98101

99102
if(!self.el.parentElement) {
100103
modalEl.addClass(self.animation);

test/html/modal.html

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ <h1 class="title">Modal</h1>
4040
<div class="modal" ng-controller="ModalCtrl">
4141
<ion-header-bar>
4242
<h1 class="title">New Contact</h1>
43+
<button class="button button-positive" ng-click="hideModal()">Close</button>
4344
</ion-header-bar>
4445
<ion-content>
4546
<div class="padding">

test/unit/angular/service/modal.unit.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('Ionic Modal', function() {
6060
it('show & remove should add .model-open to body', inject(function() {
6161
var instance = modal.fromTemplate('<div class="modal">hi</div>');
6262
instance.show();
63+
timeout.flush();
6364
expect(angular.element(document.body).hasClass('modal-open')).toBe(true);
6465
instance.remove();
6566
timeout.flush();
@@ -69,6 +70,7 @@ describe('Ionic Modal', function() {
6970
it('show & hide should add .model-open body', inject(function() {
7071
var instance = modal.fromTemplate('<div class="modal">hi</div>');
7172
instance.show();
73+
timeout.flush();
7274
expect(angular.element(document.body).hasClass('modal-open')).toBe(true);
7375
instance.hide();
7476
timeout.flush();
@@ -130,7 +132,7 @@ describe('Ionic Modal', function() {
130132
instance.$el.triggerHandler('click');
131133
expect(instance.hide).toHaveBeenCalled();
132134
});
133-
135+
134136
it('should remove click listener on hide', function() {
135137
var template = '<div class="modal"></div>';
136138
var instance = modal.fromTemplate(template);

0 commit comments

Comments
 (0)