i trying write custom increment function flipclock js. every 5-20 seconds counter incremented 1. tried surrounding clock.increment code settimeout function, not work not know looping. looked @ flipclock.js file managed make go in 0.5, 0.25 , can make delay start, cannot figure out how make increment every often. thought add delay(500) before clock.increment don't think that's loop is.
if need more info, ask.
thanks!
i couldn't find cdn hosted flipclock here code.
the counter increments +1 every 5 20 seconds.
<html> <head> <link rel="stylesheet" href="../compiled/flipclock.css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="../compiled/flipclock.js"></script> </head> <body> <div class="clock" style="margin:2em;"></div> <div class="message"></div> <script type="text/javascript"> var clock; var nextdoublejump; var internalcounter; $(document).ready(function() { internalcounter = 0; nextdoublejump = getrandomintinclusive(5, 20); console.log('next jump value: ' + nextdoublejump); clock = $('.clock').flipclock({ clockface: 'counter', autostart: false, }); setinterval(function(){ internalcounter += 1; console.log(internalcounter); if(internalcounter == nextdoublejump) { clock.increment(); nextdoublejump = getrandomintinclusive(5, 20) + internalcounter; console.log('next jump value: ' + nextdoublejump); } }, 1000); }); function getrandomintinclusive(min, max) { return math.floor(math.random() * (max - min + 1)) + min; } </script> </body> </html>
Comments
Post a Comment