Skip to content

Instantly share code, notes, and snippets.

@guest271314
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guest271314/518fd80b0cd9e4834916 to your computer and use it in GitHub Desktop.
Save guest271314/518fd80b0cd9e4834916 to your computer and use it in GitHub Desktop.
cycle.js
/*! cycle.js Copyright (c) 2014 guest271314 http://opensource.org/licenses/BSD-2-Clause
`html`
<div id="cycle">
<img src="" alt="" />
<img src="" alt="" />
<img src="" alt="" />
<img src="" alt="" />
</div>
`css`
#cycle img {
position:absolute;
opacity:0.0;
}
see http://jsfiddle.net/guest271314/4dog6za4/embedded/result/
*/
$(function () {
$.fx.interval = -1000;
(function cycle(n, cycler) {
cycler.eq(n)
.fadeTo(4000, 0.8, function () {
n = n < cycler.length - 1 ? ++n : 0;
cycle(n, cycler)
}).fadeTo(3000, 0.005);
}(0, $("#cycle img")));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment