Skip to content

Instantly share code, notes, and snippets.

@Yuffster
Created August 26, 2008 08:45
Show Gist options
  • Save Yuffster/7235 to your computer and use it in GitHub Desktop.
Save Yuffster/7235 to your computer and use it in GitHub Desktop.
var working = false; //Not currening switching content.
var newBenefit = function(e) {
if (working) return false;
working = true;
e.stop();
var cur = $$('#benefits .current')[0];
if (cur) {
var el = this;
var next = $(el.get('href').split('#')[1]);
var mleft = cur.getElement('.photo').getStyle('margin-left');
cur.getElement('.photo').get('morph').start({'margin-left': -200, 'opacity': [1, 0]});
cur.get('tween').start('opacity', 1,0).chain(function() {
cur.removeClass('current').getElement('.photo').setStyles({'margin-left': mleft, opacity:1});
next.setStyles({display:'block', opacity:0}).get('morph')
.start({'margin-left': [-200,0], 'opacity': [0, 1]})
.chain(function() { next.addClass('current').set('style', ''); });
working = false;
});
}
};
window.addEvent('domready', function() {
$$('#benefits-list a').each(function(el) {
el.addEvent('click', newBenefit.bind(el));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment