Leon.Radley.se
  • Blog
  • Labs
  • Projects
  • Leon Radley @ Google+
  • Leon Radley @ GitHub
  • Leon Radley @ Twitter
⇥
13 Dec 2011
  • mootools

MooTools Carousel

I wrote a 3D carousel in 2006. Back then it was written in the newly released ActionScript 3. But as you all know, flash isn't what all the cool guys use nowadays.

So what I've done is revamp my old code and made it a lot cooler. By using Fx.Spring I could simulate friction.

Try swiping the image. Also try it on the iPad it's touch enabled!

Demo

The tech

By using the new javascript function RequestAnimationFrame I could make it run alot smoother. Otherwise the javascript uses setTimeout(fn, 60) which causes the browser to stall if it can't handle the load.

RequestAnimationFrame handles it differently, it fires your callback whenever your system can handle it.

You also get a bonus, when the browser detects that your tab isn't visible it doesn't fire any RequestAnimationFrame.

Options

options: {
    fps: 20,
    frames: 0,
    autoPlay: true,
    resume: 3000,
    mouse: true,
    inverseMouse: false,
    move: {
        stiffness: 20,
        friction: 10,
        threshold: 0.05
    }
}

Usage

new Carousel('placeholderimageid', 'img/image-sequence{num}.jpg', {
    frames: 36,
    autoPlay: true
});

Tags

  • play| 3
  • sublime-text-2| 2
  • textmate-2| 1
  • mootools| 1
  • angular| 2
  • akka| 1
  • tip| 1
  • js| 2
  • unix| 2
All content on this site is owned by me, Leon Radley. 2010-2013 ⇪