Tuesday, July 26, 2011

This is Why You RTFM

A more accurate title might be RTFF (Read the ****ing Framework), but that doesn't have quite the same ring to it.

For a while now, I've been idly wondering how to make webOS PhoneGap apps rotate with the device orientation. I knew that there was a way to set orientation via a PhoneGap function, but I didn't bother investigating since it wasn't needed at the time. Until today. I started wondering about possible solutions, perhaps by adding event listeners to detect the orientation and set the corresponding direction.

It turns out that the answer is in the framework, underneath the orientation class.

/*
 * Manually sets the orientation of the application window.
 * 'up', 'down', 'left' or 'right' used to specify fixed window orientation
 * 'free' WebOS will change the window orientation to match the device orientation
 * @param {String} orientation
 * Example:
 *        navigator.orientation.setOrientation('up');
 */

Yes, it really is as easy as including "navigator.orientation.setOrientation('free');".

Yes, I felt twice as dumb after realizing that the reference was part of Herm's example code.

Yes, I will RTFM from now on.

No comments:

Post a Comment