Created
December 10, 2008 11:03
-
-
Save philippamarkovics/34304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Effect.Fade = function(element, options) { | |
element = $(element); | |
var oldOpacity = element.getOpacity() || '', | |
options = Object.extend({ | |
after: Prototype.emptyFunction | |
}, options || { }); | |
options.style = 'opacity:0;'; | |
options.after = options.after.wrap(function(proceed, effect) { | |
effect.element.hide().setStyle({ opacity: oldOpacity }); | |
proceed(effect); | |
}); | |
return new Effect.Morph(element, options); | |
} | |
Effect.Appear = function(element, options) { | |
element = $(element); | |
var options = Object.extend({ | |
before: Prototype.emptyFunction, | |
after: Prototype.emptyFunction | |
}, options || { }); | |
options.style = 'opacity:1;'; | |
options.before = options.before.wrap(function(proceed, effect) { | |
effect.element.setOpacity(element.visible() ? element.getOpacity() : 0.0).show(); | |
proceed(effect); | |
}); | |
return new Effect.Morph(element, options); | |
} | |
Effect.BlindUp = Class.create(Effect.Element, { | |
setup: function() { | |
this.element.makeClipping(); | |
this.originalHeight = this.element.getHeight(); | |
this.animate('style', this.element, { style: 'height:0px;' }); | |
if (!this.options.after) this.options.after = Prototype.emptyFunction; | |
this.options.after = this.options.after.wrap(function(proceed, effect) { | |
this.restoreAfter(effect); | |
proceed(effect); | |
}.bind(this)); | |
}, | |
restoreAfter: function(effect) { | |
effect.element.undoClipping().hide().setStyle({ height: this.originalHeight + 'px' }); | |
} | |
}); | |
Effect.BlindDown = Class.create(Effect.Element, { | |
setup: function() { | |
var targetHeight = this.element.getHeight(); | |
this.element.makeClipping().setStyle({ height: 0 }).show(); | |
this.animate('style', this.element, { style: 'height:' + targetHeight + 'px' }); | |
if (!this.options.after) this.options.after = Prototype.emptyFunction; | |
this.options.after = this.options.after.wrap(function(proceed, effect) { | |
effect.element.undoClipping(); | |
proceed(effect); | |
}); | |
} | |
}); | |
Effect.Puff = function(element, options) { | |
element = $(element); | |
var oldStyle = { | |
opacity: element.getOpacity(), | |
position: element.getStyle('position'), | |
top: element.style.top, left: element.style.left, | |
width: element.style.width, height: element.style.height | |
}; | |
var options = Object.extend({ | |
before: Prototype.emptyFunction, | |
after: Prototype.emptyFunction | |
}, options || { }); | |
options.before = options.before.wrap(function(proceed, effect) { | |
effect.element.absolutize(); | |
}); | |
options.after = options.after.wrap(function(proceed, effect) { | |
effect.effects[0].element.hide().setStyle(oldStyle); | |
}); | |
// TODO: insert code for Effect.Scale here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment