Skip to content

@ibolmo /Fx.Fade.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fx.Fade
Fx.Fade = new Class({
Extends: Fx.Tween,
opacity: null,
options: {
property: 'opacity'
},
set: function(property, now){
this.parent(property, now);
/* <1.3compat> */
this.element.setStyle('visibility', now ? 'visible' : 'hidden');
/* </1.3compat> */
this.opacity = null;
return this;
},
toggle: function(){
if (this.opacity == null) this.opacity = this.element.getStyle('opacity');
this.start(!this.opacity);
return this;
}
});
Element.Properties.fade = {
set: function(options){
this.get('fade').cancel().setOptions(options);
return this;
},
get: function(){
var fade = this.retrieve('fade');
if (!fade){
fade = new Fx.Fade(this, {link: 'cancel'});
this.store('fade', fade);
}
return fade;
}
};
Element.implement('fade', function(how){
var fade = this.get('fade');
if (how == null) how = 'toggle';
switch (how){
case 'in': fade.start(1); break;
case 'out': fade.start(0); break;
case 'show': fade.set(1); break;
case 'hide': fade.set(0); break;
case 'toggle': fade.toggle(); break;
default: fade.start(arguments);
}
return this;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.