mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
improve hiding status bar and reduce flickers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
(function(ionic) {
|
||||
(function(window, document, ionic) {
|
||||
|
||||
/**
|
||||
* @ngdoc utility
|
||||
@@ -56,18 +56,15 @@
|
||||
* @private
|
||||
*/
|
||||
detect: function() {
|
||||
var i, bodyClass = document.body.className;
|
||||
|
||||
ionic.Platform._checkPlatforms();
|
||||
|
||||
// only change the body class if we got platform info
|
||||
for(i = 0; i < this.platforms.length; i++) {
|
||||
bodyClass += ' platform-' + this.platforms[i];
|
||||
}
|
||||
|
||||
bodyClass += ' grade-' + this.grade;
|
||||
|
||||
document.body.className = bodyClass.trim();
|
||||
ionic.requestAnimationFrame(function(){
|
||||
// only add to the body class if we got platform info
|
||||
for(var i = 0; i < ionic.Platform.platforms.length; i++) {
|
||||
document.body.classList.add('platform-' + ionic.Platform.platforms[i]);
|
||||
}
|
||||
document.body.classList.add('grade-' + ionic.Platform.grade);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -251,15 +248,17 @@
|
||||
this._showStatusBar = val;
|
||||
this.ready(function(){
|
||||
// run this only when or if the platform (cordova) is ready
|
||||
if(ionic.Platform._showStatusBar) {
|
||||
// they do not want it to be full screen
|
||||
StatusBar.show();
|
||||
document.body.classList.remove('status-bar-hide');
|
||||
} else {
|
||||
// it should be full screen
|
||||
StatusBar.hide();
|
||||
document.body.classList.add('status-bar-hide');
|
||||
}
|
||||
ionic.requestAnimationFrame(function(){
|
||||
if(ionic.Platform._showStatusBar) {
|
||||
// they do not want it to be full screen
|
||||
StatusBar.show();
|
||||
document.body.classList.remove('status-bar-hide');
|
||||
} else {
|
||||
// it should be full screen
|
||||
StatusBar.hide();
|
||||
document.body.classList.add('status-bar-hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -268,25 +267,26 @@
|
||||
* @name ionic.Platform#fullScreen
|
||||
* @description
|
||||
* Sets whether the app is fullscreen or not (in Cordova).
|
||||
* @param {boolean} showFullScreen Whether or not to set the app to fullscreen.
|
||||
* @param {boolean=} showFullScreen Whether or not to set the app to fullscreen. Defaults to true.
|
||||
* @param {boolean=} showStatusBar Whether or not to show the device's status bar. Defaults to false.
|
||||
*/
|
||||
fullScreen: function(showFullScreen, showStatusBar) {
|
||||
// fullScreen( [showFullScreen[, showStatusBar] ] )
|
||||
// showFullScreen: default is true if no param provided
|
||||
this.isFullScreen = (showFullScreen !== false);
|
||||
|
||||
// add/remove the fullscreen classname to the body
|
||||
ionic.DomUtil.ready(function(){
|
||||
// run this only when or if the DOM is ready
|
||||
if(ionic.Platform.isFullScreen) {
|
||||
document.body.classList.add('fullscreen');
|
||||
} else {
|
||||
document.body.classList.remove('fullscreen');
|
||||
}
|
||||
ionic.requestAnimationFrame(function(){
|
||||
if(ionic.Platform.isFullScreen) {
|
||||
document.body.classList.add('fullscreen');
|
||||
} else {
|
||||
document.body.classList.remove('fullscreen');
|
||||
}
|
||||
});
|
||||
// showStatusBar: default is false if no param provided
|
||||
ionic.Platform.showStatusBar( (showStatusBar === true) );
|
||||
});
|
||||
|
||||
// showStatusBar: default is false if no param provided
|
||||
this.showStatusBar( (showStatusBar === true) );
|
||||
}
|
||||
|
||||
};
|
||||
@@ -322,4 +322,4 @@
|
||||
ionic.trigger('platformready', { target: document });
|
||||
}
|
||||
|
||||
})(window.ionic);
|
||||
})(this, document, ionic);
|
||||
|
||||
Reference in New Issue
Block a user