Results 1 to 4 of 4

Thread: How to determine current screen orientation

  1. #1
    Sencha User
    Join Date
    Jun 2009
    Posts
    419
    Vote Rating
    2
      0  

    Default How to determine current screen orientation

    Hi,

    How can I determine on an ad-hoc basis what the screen orientation is of the device being used?

    I know I can listen for the orientation change event on the viewport, but what about when the user first loads up the application, how can I determine this through code?

    Thanks

  2. #2
    Sencha User dobie_'s Avatar
    Join Date
    Sep 2011
    Location
    Seattle, WA
    Posts
    47
    Vote Rating
    0
      0  

    Default

    I would look at window.innerWidth and window.innerHeight and infer the orientation from there.

  3. #3
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    239
    Vote Rating
    2
      0  

    Default

    Yeah, that's strange to have an event to tell about value changes, but no way to get the current value.

    You could call
    Ext.Viewport.determineOrientation()
    which returns "portrait" or "landscape" but that method is not documented to be public.

    You could also look at the code (in viewport/Default.js) and copy it, or request that the method is made public.
    ExtJS 4 plugins:
    varheaders - short/normal/long column header
    clearbutton - mouseover clear button in text field
    Blog: fit4dev
    ExtJS User Group Hamburg

  4. #4
    Sencha User rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,159
    Vote Rating
    7
      0  

    Default

    Code:
    Ext.Viewport.getOrientation();
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •