Orientation Change Event Linking to a View

8 posts, 2 answers
  1. Answer
    Anthony
    Anthony avatar
    1 posts
    Member since:
    Sep 2013

    Posted 28 Sep 2013 Link to this post

    Hi,

    I have a view with a canvas on it and a drawing. I would like to change the size on the canvas and redraw the contents when the device orientation event triggers.

    So if in Portrait I would like to redraw in Landscape and vice versa.

    How do I link the  device orientation change to the current view so that I can resize the canvas and redraw the contents ?

    cheers
    Tony
  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 02 Oct 2013 Link to this post

    Hi Anthony,

    Kendo UI Mobile itself does not have built-in device orientation change events. However you can use the HTML5 Device Orientation API to achieve the functionality you are looking for.

    This looks like a good tutorial on the topic - http://www.html5rocks.com/en/tutorials/device/orientation/
     

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Anthony
    Anthony avatar
    1 posts
    Member since:
    Sep 2013

    Posted 02 Oct 2013 Link to this post

    Hi Kiril,

    That's a useful link. However what I am keen to know is how to identify the current view so that I can re-display it with different content when the orientation changes.

    I tried application.view().id  using init, show, aftershow etc and everytime the view id logged to the console was the id of the previous view.

    So I start in View1
    click to go to View2
    on show, aftershow, init etc the View Id is always the id of View 1 and not View 2

    If (as in one of the examples in the docs) I then click on a button in view 2 the id of View 2 is logged.

    So, other than adding code to track views is there a built in way to get the view id f the current view ?

    cheers
    Tony

  5. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 03 Oct 2013 Link to this post

    Hi Anthony,

    You can check the view id, using the show event of the view and the events argument. Please check the following jsBin example:

    http://jsbin.com/eZAtATi/2/edit
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Anthony
    Anthony avatar
    1 posts
    Member since:
    Sep 2013

    Posted 03 Oct 2013 Link to this post

    that works :-)

    Thanks
    Tony
  7. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 04 Oct 2013 Link to this post

    Hi Anthony,

    I am glad it helped.

    If you need any further questions, please do not hesitate to contact us.
     
    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Roman
    Roman avatar
    27 posts
    Member since:
    Sep 2013

    Posted 14 Feb 2014 Link to this post

    I'm interested in detecting changes in the device orientation too. My problem is: Using HTML 5 events would basically be fine, but I need to know when the browser is actually changing it's orientation. I (of course) don't care if someone turns it's phone around but the browser stays in it's orientation. As far as I understood the HTML 5 events, these are independent from the browser behaviour itself?
  9. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 14 Feb 2014 Link to this post

    Hi Roman,

    As I already said earlier in this ticket - Kendo UI does not supports events based on device orientation change. So if you have any questions regarding the HTML5 Device Orientation API, you can address them in forums such as stackoverflow for example

    Regards,
    Kiril Nikolov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready