I was combing the JavaScript framework blogs and came across this image carousel in JQuery: SpaceGallery. I used this same concept in my old website but it was written in mootools. The jQuery plug-in feels unresponsive and slow and doesn’t have any features. So here is the mootools version I wrote, sorry it is not as a plugin but feel free to make it into one.

Things you need
First get Mootools (This demo uses 1.2.4) and if you want the color plugin I use in the demo you can download this from mootools more.
The JavaScript
Sorry about the mess of this: I haven’t written it to be dynamic as it was rushed out late at night. The positioning of elements is hard-coded but would be simple to adapt if i could be bothered to comment anything. So here it is:
var spacers = "";
function loadDemo(){
spacers = $("spaceMan").getElements(".spaceOB");
intSpace();
}
function intSpace(){
spacers.addEvents({
'mouseover': function(){
if(this.getStyle("z-index") != 20){
this.setStyle("top", parseInt(this.getStyle("top"))-2);
}
},
'mouseout': function(){
if(this.getStyle("z-index") != 20){
this.setStyle("top", parseInt(this.getStyle("top"))+2);
}
},
'click': function(){
doSpace(this);
}
});
spacers.each(function(item, index){
var color = [index*40, 82, 87].hsbToRgb();
spacers[index].setStyles({
"z-index": 20-index,
"background-color": color
});
spacers[index].set(
'morph',
{
duration: 1000-(index*100),
transition: 'Sine:out'
}
);
spacers[index].morph(
{
opacity: [0, (100-(index*10))/100],
width: 323-(index*32.3),
height: 203-(index*20.3),
left: 60+((index*23.5)/1.5),
top: 80-(index*(15-(index)))
});
});
setTimeout(function(){$("spaceHelp").fade([0,1]);}, 1000);
}
function doSpace(el){
$("spaceHelp").fade(0);
var positionOfClicked = 20 - el.getStyle("z-index");
var topPos = 0;
spacers.each(function(item, index){
var zIndexi = parseInt(spacers[index].getStyle("z-index"));
if(zIndexi == 20){
spacers[index].setStyle("z-index", 20-(spacers.length-1));
spacers[index].set('morph', {
duration: '500',
transition: 'Sine:out',
onComplete: function(){
spacers[index].set(
'morph',
{
duration: '500',
transition: 'Sine:out'
}
);
spacers[index].morph({
opacity: [0, 0.5],
width: [94,161.5],
height: [50, 62.5],
left: [170, 138],
top: [40, 30]
});
}});
spacers[index].morph({
opacity: 0,
width: 400,
height: 220,
left: 25,
top: 110
});
}
else{
var thisPos = 20-(zIndexi+1);
spacers[index].setStyle("z-index", zIndexi+1);
spacers[index].set(
'morph',
{
duration: '500',
transition: 'Sine:out'
});
spacers[index].morph({
opacity: (100-(thisPos*10))/100,
width: 323-(thisPos*32.3),
height: 203-(thisPos*20.3),
left: 60+((thisPos*23.5)/1.5),
top: 80-(thisPos*(15-(thisPos)))
});
}
});
if(positionOfClicked == 0){
return false;
}
if(positionOfClicked != 1){
setTimeout(function(){doSpace(el)}, 125);
}
}
The CSS and HTML
The css:
#spaceManHolder{
width: 450px;
height: 500px;
margin: 40px auto 0px auto;
position: relative;
}
#spaceMan{
width: 450px;
height: 300px;
position: relative;
}
#spaceHelp{
font-size: 10px;
color: #fff;
text-align: center;
opacity: 0;
}
.spaceOB{
position: absolute;
width: 100px;
height: 100px;
z-index: 100;
}
and the html:
<div id="spaceManHolder">
<div id="spaceMan">
<div class="spaceOB"></div>
<div class="spaceOB"></div>
<div class="spaceOB"></div>
<div class="spaceOB"></div>
<div class="spaceOB"></div>
<div class="spaceOB"></div>
</div>
<div id="spaceHelp">
Click The front block or try selecting
a block from the back
</div>
</div>
If you would like to use or add to this example please do:)
merci de m’adresser le script.
Hey mate,
I’ve been looking for a nice alternative to the jQuery Space Gallery! Ta very much! Quick question for you mate, I’m fairly new to the mootools and javascript game.
I would just like to make a little change to your mootool space gallery. Basically, I’m looking to not have the images centrally aligned (as in the apple Time Machine effect!) but to have them slight fading in from the left.
Ricky is there any chance you might point me in the right direction? I’ve messing with the code but I’ve not been able to get completely as I’d like!
Cheers!
Adam
Hi Adam, Alot of the code was rushed and written poorly but i intend to make a plugin when my work dies down.
Try changing the left position to a static value so:
from -> left: 60+((thisPos*23.5)/1.5),
to -> left: 10,
I’ll get some time after Christmas to make a working plugin but this was just a concept for speed and usability.
Quality mate! Absolutely love the new site (and the new logo). I’ve been getting into some JavaScript myself recently, using the Microsoft AJAX Library, formerly known as Atlas. Just started my own site too, going to be posting some ASP.NET stuff I’ve been working on.
Keep it up mate!
Laters!
Nice Chep
dont use Microsoft AJAX Library though. Try mootools or jquery or even yahoo’s. Using M$ is like helping the devil.
Hey Ricky,
So, I’ve managed to tweak the gallery to my desires…through time and trial and error! Except for one small detail:
I have the initial positioning and image size correct. The only problem is the ‘red’ image, as you see, restarts at the first position instead of following behind the others…
Any ideas?!
Cheers
Adam
ha, sorry…here’s the link http://www.farlie.org
try changeing the last left: 60+((index*-15)), to left: ((zIndexi*15))-240, this is a hacky way of doing but it worked.
The first click doesn’t work to good though… Sorry but i’m well too busy to get into this properly. fastest way would be to add a global variable outside of the function called firstClick and set that to off/0 once the users clicked once.
Theres alot of stuff on your page that’s not needed adam, like the google analytics stuff.
Hey Ricky,
Yeh, I havent had a chance to do a real clean up yet! Its just a quick test….its also my way of learning JS!
Cheers
Hey, first time on your site, just loved it, nice Mootools plugins and Awesome design!
Keep it up!