• Stars
    star
    227
  • Rank 175,900 (Top 4 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸŒ€ 3D-perspective carousel for jQuery / Zepto

Cloud 9 Carousel

A 3D perspective carousel for jQuery/Zepto focused on performance, based on the original Cloud Carousel by Professor Cloud.

Features

Demos

Endangered species Web browsers Julemagne.com Flat top-down layout demo

View the examples in the gh-pages branch.

Dependencies

Documentation

Basic usage

HTML:

<div id="carousel">
  <img class="cloud9-item" src="images/1.png" alt="Item #1">
  <img class="cloud9-item" src="images/2.png" alt="Item #2">
  <img class="cloud9-item" src="images/3.png" alt="Item #3">
  <img class="cloud9-item" src="images/4.png" alt="Item #4">
  <img class="cloud9-item" src="images/5.png" alt="Item #5">
  <img class="cloud9-item" src="images/6.png" alt="Item #6">
</div>

<div id="buttons">
  <button class="left">
    ←
  </button>
  <button class="right">
    β†’
  </button>
</div>

CSS:

#carousel .cloud9-item, #buttons button {
  cursor: pointer;
}

JavaScript:

$("#carousel").Cloud9Carousel( {
  buttonLeft: $("#buttons > .left"),
  buttonRight: $("#buttons > .right"),
  autoPlay: 1,
  bringToFront: true
} );

Carousel options

You may pass these options to the carousel constructor. Some of these properties may be changed during runtime via the data handle.

Option Description Default
xOrigin Center of the carousel (x coordinate) (container width / 2)
yOrigin Center of the carousel (y coordinate) (container height / 10)
xRadius Half the width of the carousel (container width / 2.3)
yRadius Half the height of the carousel (container height / 6)
farScale Scale of an item at its farthest point (range: 0 to 1) 0.5
mirror See: Reflection options none
transforms Use native CSS transforms if support for them is detected true
smooth Use maximum effective frame rate via the requestAnimationFrame API if support is detected true
fps Frames per second (if smooth animation is turned off) 30
speed Relative speed factor of the carousel. Any positive number: 1 is slow, 4 is medium, 10 is fast. Adjust to your liking 4
autoPlay Automatically rotate the carousel by this many items periodically (positive number is clockwise). Auto-play is not performed while the mouse hovers over the carousel container. A value of 0 means auto-play is turned off. See: autoPlayDelay 0
autoPlayDelay Delay, in milliseconds, between auto-play spins 4000
mouseWheel Spin the carousel using the mouse wheel. Requires a "mousewheel" event, provided by this mousewheel plugin. However, see: known issues false
bringToFront Clicking an item will rotate it to the front false
buttonLeft jQuery collection of element(s) intended to spin the carousel so as to bring the item to the left of the frontmost item to the front, i.e., spin it counterclockwise, when clicked. E.g., $("#button-left") none
buttonRight jQuery collection of element(s) intended to spin the carousel so as to bring the item to the right of the frontmost item to the front, i.e., spin it clockwise, when clicked. E.g., $("#button-right") none
itemClass Class attribute of the item elements inside the carousel container "cloud9-item"
frontItemClass Class attribute automatically added to the front-most item element none
handle The string handle you can use to interact with the carousel. E.g., $("#carousel").data("carousel").go(1) "carousel"

Reflection options

After including reflection.js in your page, you may pass in options to configure the item reflections. For example:

mirror: {
  gap: 12,     /* 12 pixel gap between item and reflection */
  height: 0.2, /* 20% of item height */
  opacity: 0.4 /* 40% opacity at the top */
}

Note: The reflection.js plugin does not work with Zepto, but this unofficial fork does!

Option Description Default
gap Vertical gap in pixels between the bottom of the item (at full size) and the top of its reflection 2
height The height of the reflection relative to the height of the item (range: 0 to 1) 1/3
opacity Opacity of the reflection at its top (most visible part) (range: 0 to 1) 0.5

Carousel methods

The following methods can be called on the carousel object after initialisation. For example:

// Spin three items clockwise
$("#carousel").data("carousel").go( 3 );

Basic methods:

Method Description Arguments
go( count ) Spin the carousel count: Number of carousel items to rotate (+ is clockwise, - is counterclockwise)
goTo( index ) Spin the carousel to a specific item index: Index of the carousel item to rotate to
nearestIndex() Returns the 0-based index of the item nearest to the front (integer) none
nearestItem() Returns a reference to the item object of the item that is nearest to the front (Item object) none
deactivate() Disable the carousel (currently irreversible). You can use that in order to halt the carousel mechanism and free the carousel's elements from it. Then the elements can be manipulated without interference from the carousel plugin. See for example, when you click to expand the gallery. none

Advanced methods:

Method Description Arguments
itemsRotated() Returns the interpolated number of items rotated from the initial zero position. In a carousel with 5 items that made three clockwise revolutions, the value will be -15. If the carousel then further spins half-way to the next item, then the value would be -15.5 (float) none
floatIndex() Returns an interpolated value of the item "index" at the front of the carousel. If, for example, the carousel was 20% past item 2 toward the next item, then floatIndex() would return 2.2 (float) none

Event callbacks

Callback functions may be passed to the carousel constructor along with the options. For example:

// Hide carousel while items are loading
$("#carousel").css( 'visibility', 'hidden' ).Cloud9Carousel( {
  bringToFront: true,
  onLoaded: function( carousel ) {
    // Show carousel
    $(carousel).css( 'visibility', 'visible' );
    alert( 'Carousel is ready!' );
  },
  onRendered: function( carousel ) {
    var item = $(carousel).data("carousel").nearestItem();
    console.log( "Item closest to the front: " + $(item).attr("alt") );
  }
} );
Callback Description
onLoaded Fires once when the carousel has completely initialised
onRendered Fires each time after a frame has finished calculating
onAnimationFinished Fires when the carousel has finished spinning

Further questions?

Please check what's been asked. If not, take your time and ask a good one.

Authors

Known issues

  • Due to lack of standartisation, "mousewheel" scrolling is extremely sensitive and unmanageable when using some track pads (such as on the MacBook Pro). Unfortunately, since there appears to be no way to know directly what type of device is triggering the mousewheel events, it is not trivial to somehow normalise or "tame" the input from the track pad without also affecting the "1 tick per click" behaviour of the standard mouse wheel. darsain has described the same phenomenon in this discussion at the sly.js project. Ideas are appreciated.

License

MIT

More Repositories

1

facebook-cli

πŸ’» Facebook command line client (needs to be updated)
Ruby
389
star
2

bitly-client

πŸ”— Create and manage your Bitly shortlinks from the command line
JavaScript
50
star
3

meetup-cli

πŸ• Track upcoming and past meetup events (needs to be updated)
Ruby
43
star
4

clojurescript-nodejs-starter-kit

πŸ—οΈ Quickstarter kit for a NodeJS application using ClojureScript and Boot
Clojure
12
star
5

facebook-friends

πŸ‘ͺ Your Facebook friends all on one page
JavaScript
9
star
6

bender

⌨️ Futuristic two-line zsh prompt with git integration
9
star
7

tileview

πŸ–ŒοΈ How well does an image tile? Check with this Chrome extension
JavaScript
9
star
8

facebook-browser

πŸ” Quickly search Facebook pages by name
Elm
8
star
9

specious.github.io

πŸ“± Online business card
HTML
5
star
10

check-bitly

πŸ‘Œ Check web domains to find out if they are bitly.com domains
Shell
5
star
11

letmein

πŸ‘‹ Automatic authentication with wifi hotspot captive portals
Shell
4
star
12

dotfiles

πŸ”§ my config files > http://dotfiles.github.io/inspiration/
Shell
4
star
13

facebook-indexer

🌟 Generate an index of the Facebook pages you follow
Shell
3
star
14

blog

πŸ“ I might publish some articles
HTML
2
star
15

portfolio

🌠 My retired freelance portfolio (2012 - 2014)
JavaScript
1
star
16

present

🌠 Responsive-design portfolio gallery with contact form
JavaScript
1
star
17

css-flag-of-america

πŸ‡ΊπŸ‡Έ Flag of the United States rendered in pure CSS
CSS
1
star
18

specious

My banner
1
star
19

htmlflow

Lightweight HTML formatter that uses htmlparser2
JavaScript
1
star
20

facebook-buddy

πŸ‘₯ Chrome extension that adds unofficial features when browsing facebook.com
JavaScript
1
star
21

projects

πŸ’Ό Things I've brought into this world
JavaScript
1
star
22

polyglot

Interactive prompt that translates text to multiple languages simultaneously
Shell
1
star
23

sudoku-solver

Solves classic 9x9 sudoku puzzles
JavaScript
1
star
24

julemagne

🎨 Browse and purchase fine art by Julie David
JavaScript
1
star