Rankinstudio
Rankinstudio

Reputation: 612

Warp.js help Javascript Change Time Speed

I'm working on a project where it is important that I can manipulate time speed. This JS module:

https://github.com/mattbradley/warpjs/blob/master/README.md

seems to be exactly what I need, but I don't think I'm trying to use it right. I can't get the .speed([]); to change the time rate. Here is my example:

    <html>
        <head>
        </head>

    <body>
        <script src="jquery.min.js"></script>
        <script src="warp.js"></script>


        <div id="container"></div>
        <span id="info"></span><br>
        <span id="time"></span>
        <span id="time2"></span>

        <script>


      setInterval(function() {
        var now = new Date;
        now = Date.warp.clock(true);
        //now = Date.warp.speed([1]); // DOESNT WORK?

        var dateD = [now.getMonth() + 1,now.getDate(),now.getFullYear()];
        var dateE = [now.getHours(),now.getMinutes(),now.getSeconds()];
        var MDY = dateD.join("/");
        var HMS = dateE.join(":");
        time.innerHTML = (MDY);
        time2.innerHTML = (HMS);

      }, 20);


        </script>

    </body>

    </html>

Upvotes: 0

Views: 104

Answers (1)

Carlos Sultana
Carlos Sultana

Reputation: 709

Date.warp.speed(1); will work, the brackets in the function documentation mean it is an optional parameter. If you look at the source on line 131 the speed method sets tickSpeed which is an integer

Upvotes: 1

Related Questions