mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Platform isPortrait/isLandscape
This commit is contained in:
@@ -165,10 +165,11 @@ function initApp(window, document, config) {
|
||||
// Platform is a global singleton
|
||||
Platform.url(window.location.href);
|
||||
Platform.userAgent(window.navigator.userAgent);
|
||||
Platform.width(window.innerWidth);
|
||||
Platform.height(window.innerHeight);
|
||||
Platform.load(config);
|
||||
|
||||
// on resize be sure to clear out existing window dimensions
|
||||
window.addEventListener('resize', Platform.resetDimensions);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,18 +106,32 @@ export class PlatformCtrl {
|
||||
return this._ua;
|
||||
}
|
||||
|
||||
width(val) {
|
||||
if (arguments.length) {
|
||||
this._w = val;
|
||||
width() {
|
||||
if (!this._w) {
|
||||
this._w = window.innerWidth;
|
||||
this._h = window.innerHeight;
|
||||
}
|
||||
return this._w || 0;
|
||||
return this._w;
|
||||
}
|
||||
|
||||
height(val) {
|
||||
if (arguments.length) {
|
||||
this._h = val;
|
||||
height() {
|
||||
if (!this._h) {
|
||||
this._w = window.innerWidth;
|
||||
this._h = window.innerHeight;
|
||||
}
|
||||
return this._h || 0;
|
||||
return this._h;
|
||||
}
|
||||
|
||||
isPortrait() {
|
||||
return this.width() < this.height();
|
||||
}
|
||||
|
||||
isLandscape() {
|
||||
return !this.isPortrait();
|
||||
}
|
||||
|
||||
resetDimensions() {
|
||||
this._w = this._h = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user