@@ -41,7 +41,8 @@ angular.module('ionic.service.loading', [])
41
41
'$q' ,
42
42
'$log' ,
43
43
'$compile' ,
44
- function ( $animate , $document , $ionicTemplateLoader , $ionicBackdrop , $timeout , $q , $log , $compile ) {
44
+ '$animateClassToggler' ,
45
+ function ( $animate , $document , $ionicTemplateLoader , $ionicBackdrop , $timeout , $q , $log , $compile , $animateClassToggler ) {
45
46
46
47
var loaderInstance ;
47
48
//default value
@@ -81,13 +82,17 @@ function($animate, $document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q
81
82
appendTo : $document [ 0 ] . body
82
83
} )
83
84
. then ( function ( loader ) {
85
+
86
+ var toggler = $animateClassToggler ( loader . element , 'ng-hide' ) ;
87
+
84
88
loader . show = function ( options ) {
85
89
var self = this ;
86
90
var templatePromise = options . templateUrl ?
87
91
$ionicTemplateLoader . load ( options . templateUrl ) :
88
92
//options.content: deprecated
89
93
$q . when ( options . template || options . content || '' ) ;
90
94
95
+
91
96
if ( ! this . isShown ) {
92
97
//options.showBackdrop: deprecated
93
98
this . hasBackdrop = ! options . noBackdrop && options . showBackdrop !== false ;
@@ -111,26 +116,16 @@ function($animate, $document, $ionicTemplateLoader, $ionicBackdrop, $timeout, $q
111
116
}
112
117
} ) ;
113
118
119
+ toggler . removeClass ( ) ;
120
+ ionic . DomUtil . centerElementByMarginTwice ( this . element [ 0 ] ) ;
114
121
this . isShown = true ;
115
- ionic . requestAnimationFrame ( function ( ) {
116
- if ( self . isShown ) {
117
- $animate . removeClass ( self . element , 'ng-hide' ) ;
118
- //Fix for ios: if we center the element twice, it always gets
119
- //position right. Otherwise, it doesn't
120
- ionic . DomUtil . centerElementByMargin ( self . element [ 0 ] ) ;
121
- //One frame after it's visible, position it
122
- ionic . requestAnimationFrame ( function ( ) {
123
- ionic . DomUtil . centerElementByMargin ( self . element [ 0 ] ) ;
124
- } ) ;
125
- }
126
- } ) ;
127
122
} ;
128
123
loader . hide = function ( ) {
129
124
if ( this . isShown ) {
130
125
if ( this . hasBackdrop ) {
131
126
$ionicBackdrop . release ( ) ;
132
127
}
133
- $animate . addClass ( this . element , 'ng-hide' ) ;
128
+ toggler . addClass ( ) ;
134
129
}
135
130
$timeout . cancel ( this . durationTimeout ) ;
136
131
this . isShown = false ;
0 commit comments