// use helper method to generate an array of image urls. We have 34 frames in total
var frames = SpriteSpin.sourceArray('http://spritespin.ginie.eu/images/rad_zoom_{frame}.jpg', {
frame: [1, 34],
digits: 3
});
// these are the frame numbers that will show a detail bubble
var details = [0, 8, 20];
// the current index in the details array
var detailIndex = 0;
// initialise spritespin
var spin = $('#spritespin');
spin.spritespin({
source: frames,
width: 480,
sense: -1,
height: 327,
animate: false
});
// get the api object. This is used to trigger animation to play up to a specific frame
var api = spin.spritespin("api");
spin.bind("onLoad", function(){
var data = api.data;
data.stage.prepend($(".details .detail")); // add current details
data.stage.find(".detail").hide(); // hide current details
}).bind("onFrame", function(){
var data = api.data;
data.stage.find(".detail:visible").stop(false).fadeOut();
data.stage.find(".detail.detail-" + data.frame).stop(false).fadeIn();
});
$( "#prev" ).click(function(){
setDetailIndex(detailIndex - 1);
});
$( "#next" ).click(function(){
setDetailIndex(detailIndex + 1);
});
function setDetailIndex(index){
detailIndex = index;
if (detailIndex < 0){
detailIndex = details.length - 1;
}
if (detailIndex >= details.length){
detailIndex = 0;
}
api.playTo(details[detailIndex]);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.