Hi Julien,
https://ionicframework.com/docs/v2/api/platform/Platform/
width()
Gets the width of the platform's viewport using window.innerWidth. Using this
method is preferred since the dimension is a cached value, which reduces the
chance of multiple and expensive DOM reads.
height()
Gets the height of the platform's viewport using window.innerHeight. Using this
method is preferred since the dimension is a cached value, which reduces the
chance of multiple and expensive DOM reads.
1. Please try using window.innerHeight and window.innerWidth to get height
and width of the device at first.
2. Try
// Add readySource to check if platform ready was used. The resolved value is
the readySource, which states which platform ready was used.
// For example, when Cordova is ready, the resolved ready source is cordova.
The default ready source value will be dom.
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
@Component({...})
export MyApp {
constructor(platform: Platform) {
platform.ready().then((readySource) => {
console.log('Platform ready from', readySource);
console.log('Width: ' + platform.width());
console.log('Height: ' + platform.height());
});
}
3. Remove Crosswalk in Ionic 2 to check if system webview can get correct
results, then it should be Crosswalk issue rather than Ionic issue.
Relevant topic:
https://forum.ionicframework.com/t/how-to-get-device-width-and-height/28372
BR
Belem
From: Crosswalk-help
[mailto:[email protected]] On Behalf Of Julien
CASTRIE
Sent: Monday, November 21, 2016 7:52 PM
To: [email protected]
Subject: [Crosswalk-help] Is there an event to look for in Crosswalk before
checking browser height and width?
This is linked to a question I've posted on StackOverflow:
http://stackoverflow.com/questions/40718494/ionic-2-crosswalk-for-android-this-platform-height-width-inconsistent-resul
I have trouble getting the accurate height and width of the web browser since I
have installed crosswalk in my Ionic 2 project. In Ionic 2, one needs to wait
for this.platform.ready() event. By proceeding like that I don't get
consistently the right height and width (it is either correct or equal to 0).
My guess is that I need to watch for another event controlled by Crosswalk. I
had a look at the documentation and found nothing dealing with that topic so
far, so I ask to experienced Crosswalk user whom could have an idea.
[http://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]?v=73d79a89bded&a]<http://stackoverflow.com/questions/40718494/ionic-2-crosswalk-for-android-this-platform-height-width-inconsistent-resul>
Ionic 2 Crosswalk for Android: this.platform.height()/width() inconsistent
result on this.platform.ready()
event<http://stackoverflow.com/questions/40718494/ionic-2-crosswalk-for-android-this-platform-height-width-inconsistent-resul>
stackoverflow.com
I use Crosswalk plugin for Android with Ionic 2 and I've noticed, when running
on a real device, that this gives an inconsistent result:
this.platform.ready().then(() => { console.log(...
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help