This is a migrated thread and some comments may be shown as answers.

Orientation Change Event Linking to a View

7 Answers 329 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Anthony asked on 28 Sep 2013, 05:12 PM
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

7 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 02 Oct 2013, 05:07 AM
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!
0
Anthony
Top achievements
Rank 1
answered on 02 Oct 2013, 09:54 PM
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

0
Accepted
Kiril Nikolov
Telerik team
answered on 03 Oct 2013, 07:33 AM
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!
0
Anthony
Top achievements
Rank 1
answered on 03 Oct 2013, 06:37 PM
that works :-)

Thanks
Tony
0
Kiril Nikolov
Telerik team
answered on 04 Oct 2013, 06:52 AM
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!
0
Roman
Top achievements
Rank 1
answered on 14 Feb 2014, 10:36 AM
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?
0
Kiril Nikolov
Telerik team
answered on 14 Feb 2014, 02:17 PM
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!
Tags
General Discussions
Asked by
Anthony
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Anthony
Top achievements
Rank 1
Roman
Top achievements
Rank 1
Share this question
or