Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widthPixels of "tns-core-modules/platform" is incorrect inside the orientationChanged event #6314

Open
VladimirAmiorkov opened this issue Sep 27, 2018 · 0 comments · May be fixed by #10530
Open

Comments

@VladimirAmiorkov
Copy link
Contributor

VladimirAmiorkov commented Sep 27, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants