Skip to content

Commit cb36869

Browse files
committed
fix(loading): stop resize flicker when showing & changing text
1 parent 81a7342 commit cb36869

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

Diff for: js/angular/service/loading.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
var LOADING_TPL =
3-
'<div class="loading">' +
3+
'<div class="loading-container">' +
4+
'<div class="loading">' +
5+
'</div>' +
46
'</div>';
57

68
var LOADING_HIDE_DEPRECATED = '$ionicLoading instance.hide() has been deprecated. Use $ionicLoading.hide().';
@@ -109,17 +111,16 @@ function($document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q, $log, $c
109111

110112
templatePromise.then(function(html) {
111113
if (html) {
112-
self.element.html(html);
113-
$compile(self.element.contents())(self.scope);
114+
var loading = self.element.children();
115+
loading.html(html);
116+
$compile(loading.contents())(self.scope);
114117
}
115118

116119
//Don't show until template changes
117120
if (self.isShown) {
118121
self.element.addClass('visible');
119-
ionic.DomUtil.centerElementByMarginTwice(self.element[0]);
120122
ionic.requestAnimationFrame(function() {
121123
self.isShown && self.element.addClass('active');
122-
ionic.DomUtil.centerElementByMarginTwice(self.element[0]);
123124
$document[0].body.classList.add('loading-active');
124125
});
125126
}

Diff for: scss/_loading.scss

+24-16
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@
44
* --------------------------------------------------
55
*/
66

7-
.loading {
8-
@include transition(0.2s opacity linear);
7+
.loading-container {
8+
position: absolute;
9+
left: 0;
10+
top: 0;
11+
right: 0;
12+
bottom: 0;
13+
14+
z-index: $z-index-loading;
915

16+
@include display-flex();
17+
@include justify-content(center);
18+
@include align-items(center);
19+
20+
@include transition(0.2s opacity linear);
1021
visibility: hidden;
1122
opacity: 0;
1223

@@ -17,23 +28,20 @@
1728
opacity: 1;
1829
}
1930

20-
position: fixed;
21-
top: 50%;
22-
left: 50%;
31+
.loading {
32+
padding: $loading-padding;
2333

24-
z-index: $z-index-loading;
25-
padding: $loading-padding;
26-
27-
border-radius: $loading-border-radius;
28-
background-color: $loading-bg-color;
34+
border-radius: $loading-border-radius;
35+
background-color: $loading-bg-color;
2936

30-
color: $loading-text-color;
37+
color: $loading-text-color;
3138

32-
text-align: center;
33-
text-overflow: ellipsis;
34-
font-size: $loading-font-size;
39+
text-align: center;
40+
text-overflow: ellipsis;
41+
font-size: $loading-font-size;
3542

36-
h1, h2, h3, h4, h5, h6 {
37-
color: $loading-text-color;
43+
h1, h2, h3, h4, h5, h6 {
44+
color: $loading-text-color;
45+
}
3846
}
3947
}

0 commit comments

Comments
 (0)