Hi, I'd like my page to refresh and change a tiggr component whenever the mobile device is shaken, i believe I can do this with the phonegap API? Could you please explain how this is done?
Regards,
Jaimee
Hi, I'd like my page to refresh and change a tiggr component whenever the mobile device is shaken, i believe I can do this with the phonegap API? Could you please explain how this is done?
Regards,
Jaimee
Yes, you can do it with PhoneGap API: http://docs.phonegap.com/en/1.3.0/pho.... Here is how to use PhoneGap API in Tiggr: http://help.gotiggr.com/documentation.... Let us know if you have any other questions.
Hi Max,
I understand how I can use code on an event on a component, but what I would like is to have the app react when the phone is shaken. Where would I start to put the code for this?
Would it be upon page load?
Regards,
Jaimee
Once you get x, y, and z coordinates from: http://docs.phonegap.com/en/1.2.0/pho..., you can determine (based on app logic) whether the app should react to this change.
Where do I place the code to have it react?
Also, I'd really like to have the user 'swipe' pages left or right and have the app recat by changing the page. Where would I put code for that type of input?
Here is an example (from PhoneGap API):
Create a new JavaScript file, any name will do:
code
// The watch id references the current 'watchAcceleration'
var watchID = null;
Code: Select all
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
startWatch();
}
// Start watching the acceleration
//
function startWatch() {
// Update acceleration every 3 seconds
var options = { frequency: 3000 };
watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);
}
// Stop watching the acceleration
//
function stopWatch() {
if (watchID) {
navigator.accelerometer.clearWatch(watchID);
watchID = null;
}
}
// onSuccess: Get a snapshot of the current acceleration
//
function onSuccess(acceleration) {
var element = Tiggr('mobilelabel1');
element.html('Acceleration X: ' + acceleration.x + '<br />' +
'Acceleration Y: ' + acceleration.y + '<br />' +
'Acceleration Z: ' + acceleration.z + '<br />' +
'Timestamp: ' + acceleration.timestamp + '<br />');
}
// onError: Failed to get the acceleration
//
function onError() {
alert('onError!');
}
/code
Place Label component on a screen (default text: Waiting...), the component name should be 'mobilelabel1' (if you change the name, update the reference in onSuccess function.
Run the app on the device or via Tiggr Mobile Tester.
As for swipe events, here is how to do it: http://getsatisfaction.com/gotiggr/to...