Created
May 5, 2011 11:24
-
-
Save akoppela/956894 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
LSD.Mixin.Animation = new Class({ | |
behaviour: '[animation]', | |
options: { | |
animation: {} | |
}, | |
getAnimation: function() { | |
if (!this.animation) { | |
this.animation = this.getAnimatedElement().set('tween', this.options.animation).get('tween'); | |
if (this.options.animation.value) this.animation.set(this.options.animation.value); | |
} | |
return this.animation; | |
}, | |
fade: function(how){ | |
return this.getAnimation().start('opacity', how == 'in' ? 1 : 0); | |
}, | |
slide: function(how){ | |
console.info(this.getAnimatedElement().scrollHeight); | |
return this.getAnimation().start('height', how == 'in' ? this.getAnimatedElement().scrollHeight - this.getAnimatedElement().offsetHeight : 0); | |
}, | |
show: function() { | |
var parent = this.parent; | |
this.getAnimatedElement().setStyle('display', this.getAnimatedElement().retrieve('style:display') || 'inherit'); | |
this[this.attributes.animation]('in').chain(function(){ | |
LSD.Widget.prototype.show.apply(this, arguments); | |
}.bind(this)); | |
}, | |
hide: function(how) { | |
var parent = this; | |
this[this.attributes.animation]('out').chain(function(){ | |
this.getAnimatedElement().store('style:display', this.getAnimatedElement().getStyle('display')); | |
this.getAnimatedElement().setStyle('display', 'none'); | |
LSD.Widget.prototype.hide.apply(this, arguments); | |
}.bind(this)); | |
}, | |
remove: function() { | |
return this[this.attributes.animation]('out').chain(this.dispose.bind(this)); | |
}, | |
dispose: function() { | |
return this.getAnimatedElement().dispose() | |
}, | |
getAnimatedElement: function() { | |
return this.element; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment