none
How to setup a timer to calculate the speed of mouse rotation movements on screen? RRS feed

  • Question

  • Hi,

    After a long gap I am writing small project, WebForms to calculate the mouse rotation movement speed. Also the timer has to analyse, the clock wise direction speed only. Suppose if there is any Anti-Clock wise direction mouse movements, then the timer no need to calculate the speed. Therefore the speed calculation is required for clock wise directions only.

    As a initial start-up, I draw a circle to centre of screen. And also I detect the direction of mouse rotation movements. ok. But I don't know how to setup the timer & measure it's speed. Any guidance & helps will be great.

    Thanks

    My Codes:-

       

    <div id="Divn1" onmousemove="MyNewFunction(event)" onmouseout="ClearCoor()" style="width:99%; height:99%; border:solid;background-color:white; ;"> <p id="Demo1"></p> <div id="Divn2" style="width:50px;height:50px;border-radius:50%;background-color:brown; ; top:45%; margin-left:47%;"> </div> </div>

        <script>
            function MyNewFunction(e)
            {
                var oldx = 0;
                var oldy = 0;
                if (e.movementX < oldx) {
                    XDirection = "left"
                } else if (e.movementX > oldx) {
                    XDirection = "right"
                }
      
                oldx = e.pageX;
                oldY = e.pageY;
                document.getElementById("Demo1").innerHTML = XDirection;
            }
            function ClearCoor()
            {
                document.getElementById("Demo1").innerHTML = "";
            }
        </script>

    Note : Above code will show a circle on center of page & will show the mouse rotation direction. But need to analyse the speed by timer...

    Thanks for the helps again.


    U.PARANTHAMAN

    • Moved by CoolDadTx Sunday, June 11, 2017 10:26 PM ASP.NET related
    Sunday, June 11, 2017 9:19 AM

All replies