Create a gist now

Instantly share code, notes, and snippets.

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');
return this;
Element.Properties.fade = {
set: function(options){
return this;
get: function(){
var fade = this.retrieve('fade');
if (!fade){
fade = new Fx.Fade(this, {link: 'cancel'});'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