script.js 548 B

1234567891011121314151617181920212223242526272829303132
  1. $(document).ready(function() {
  2. var fps = 2, now, then = Date.now(), interval = 1000/fps, delta;
  3. function init(){
  4. console.log("Init");
  5. // preload all pictures before launching
  6. setTimeout(function(){
  7. play();
  8. }, 5000);
  9. };
  10. function play(millis){
  11. requestAnimationFrame(play);
  12. now = Date.now();
  13. delta = now - then;
  14. if(delta > interval){
  15. $(".frame.current", "#pictures").toggleClass('current').next().toggleClass('current');
  16. then = now -(delta % interval);
  17. }
  18. }
  19. init();
  20. });