gyroscope iphone
<p>Im rotating a cube with the below function and need to know how to stop listening to it because i want to apply touch movements also and right now the gyroscope overrides the touch and makes a weird behaviour. </p>

<p>I thought putting an if and a variable isTouched and setting it to true when is touched should work but does not, any idea how to obtain that behaviour? </p>

<pre><code>function sas_rotationUpdate(x, y, z) {
        angleX += (90 * parseInt((50 * x) / 90))*2;
        angleY += (90 * parseInt((50 * y) / 90))*2;
        angleZ += (90 * parseInt((50 * z) / 90))*2;
        document.getElementById('cube').style.webkitTransform = "rotateX(" + angleX + "deg) rotateY(" + angleY + "deg)  rotateZ(" + angleZ + "deg)";
        if(isTouched === true){return;}
    }   

window.addEventListener('touchstart', function (event) {
    isTouched = true;
}
</code></pre>

<p>EDIT<br>
Tried also backwards as </p>

<pre><code>if (isTouched === false){
        function sas_rotationUpdate(x, y, z) {
            angleX += (90 * parseInt((50 * x) / 90))*2;
            angleY += (90 * parseInt((50 * y) / 90))*2;
            angleZ += (90 * parseInt((50 * z) / 90))*2;
            document.getElementById('cube').style.webkitTransform = "rotateX(" + angleX + "deg) rotateY(" + angleY + "deg)  rotateZ(" + angleZ + "deg)";
        }
    }
</code></pre>

<p>But doesnt work either. I Im using this <a href="http://help.smartadserver.com/iOS/V3.1.2/html/docs/companion/htmlcreatives.html#orientation" rel="nofollow">documentation</a>, anyone with experience in it?</p>

<p>2nd EDIT, putting the if at the top of the function and applying it only for the css change works for me now, hope Is helpfull and i dont get banned again due to the most than probable tumbleweed awarding this question.</p>
