Skip to content

Instantly share code, notes, and snippets.

@jjulian
Created November 24, 2012 23:19
Show Gist options
  • Save jjulian/4141779 to your computer and use it in GitHub Desktop.
Save jjulian/4141779 to your computer and use it in GitHub Desktop.
A simple carousel implemented with a single Backbone view
@domnerus
Copy link

domnerus commented Apr 1, 2014

Hi, can this carousel have autoplay by default?

Great job, it looks I could use it without much hassle tampering with server files and javascript.

Thanks

@jjulian
Copy link
Author

jjulian commented Apr 1, 2014

Sure it can! You just need to set up a thread to do the rotation after a period of time. Add this code (untested), then call start(5000) after the carousel is created:

  start: function(delay) {
    this.delay = delay;
    this.nextRotationID = setTimeout(this.rotate, this.delay);
  },
rotate: function() {
    this.next();
    this.nextRotationID = setTimeout(this.rotate, this.delay);
  }

@djdevil1989
Copy link

Cool carousel, however it has a bug, when clicking next or back twice fast (which can happen on people that dont yet know single click is enough) it shows the next picture under the first instead of skipping to the next

@RtzS
Copy link

RtzS commented Jul 7, 2014

Can i use this carousel with touch swipe effect?

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment