Closed
Description
Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?
Yes
Tell us about the problem
Using the screen.mainScreen.widthPixels
from "tns-core-modules/platform"
inside the application orientationChanged
event returns the previous orientation's size.
Which platform(s) does your issue occur on?
Tested on Android
Please provide the following version numbers that your issue occurs with:
- CLI: (run
tns --version
to fetch it) - Cross-platform modules: 4.2.0
- Runtime(s): 4.2.0
- Plugin(s): (look for the version number in the
package.json
file of your
project)
"dependencies": {
"@angular/common": "~6.1.0",
"@angular/compiler": "~6.1.0",
"@angular/core": "~6.1.0",
"@angular/forms": "~6.1.0",
"@angular/http": "~6.1.0",
"@angular/platform-browser": "~6.1.0",
"@angular/platform-browser-dynamic": "~6.1.0",
"@angular/router": "~6.1.0",
"@ngrx/store": "4.1.1",
"nativescript-angular": "^6.0.0",
"nativescript-camera": "4.0.2",
"nativescript-floatingactionbutton": "4.1.3",
"nativescript-fresco": "4.0.0",
"nativescript-google-analytics": "0.4.4",
"nativescript-image-swipe": "3.0.0",
"nativescript-imagepicker": "6.0.3",
"nativescript-iqkeyboardmanager": "1.1.0",
"nativescript-orientation": "^2.2.0",
"nativescript-toasty": "^1.1.5",
"nativescript-ui-listview": "^3.5.11",
"nativescript-ui-sidedrawer": "^4.3.0",
"reflect-metadata": "0.1.10",
"rxjs": "~6.1.0",
"rxjs-compat": "^6.2.2",
"tns-core-modules": "^4.2.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "~6.1.0",
"@ngtools/webpack": "~6.1.0",
"nativescript-dev-typescript": "~0.7.2",
"nativescript-dev-webpack": "^0.15.1",
"tns-platform-declarations": "4.2.0",
"typescript": "~2.8.2"
},
Please tell us how to recreate the issue in as much detail as possible.
Attach to the application's orientationChangedEvent
and try to retrieve the screen's width in Pixels
import * as applicationModule from 'tns-core-modules/application';
import { screen } from "tns-core-modules/platform";
...
const screeWidth = screen.mainScreen.widthPixels
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.