facebook

Regarding: Adding an "OnClick" function

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #341833 Reply

    SKnoxmn
    Member

    I’d like to have this fired off from an “OnClick” function of a button, rather than “onLoad”. I’d also like to know how to stop it doing continuous updates. Example. Click a second time, or run for 2 seconds and stop.

    if (window.DeviceOrientationEvent) {
    console.log(“DeviceOrientation is supported”);
    window.addEventListener(‘deviceorientation’, function(eventData) {
    var Cant = eventData.gamma;
    var Angle = eventData.beta;
    var Dir = eventData.webkitCompassHeading;// take webkitcompass out of here
    deviceOrientationHandler(Cant, Angle, Dir);
    }, false);
    } else {
    alert(“Not supported on your device or browser. Sorry.”);
    }

    function deviceOrientationHandler(Cant, Angle, Dir){
    $(‘#m1-Learning-textField4’).val(Angle);
    $(‘#m1-Learning-textField5’).val(Dir);
    }

    -SKnox

Viewing 1 post (of 1 total)
Reply To: Regarding: Adding an "OnClick" function

You must be logged in to post in the forum log in