Sha256: d19ced50a30eda244f4fcde6c5113a3c0fa8e36ad757befeb1810a11fd9cddff

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

/*
---

name: Fx.Morph

description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.

license: MIT-style license.

requires: Fx.CSS

provides: Fx.Morph

...
*/

Fx.Morph = new Class({

	Extends: Fx.CSS,

	initialize: function(element, options){
		this.element = this.subject = document.id(element);
		this.parent(options);
	},

	set: function(now){
		if (typeof now == 'string') now = this.search(now);
		for (var p in now) this.render(this.element, p, now[p], this.options.unit);
		return this;
	},

	compute: function(from, to, delta){
		var now = {};
		for (var p in from) now[p] = this.parent(from[p], to[p], delta);
		return now;
	},

	start: function(properties){
		if (!this.check(properties)) return this;
		if (typeof properties == 'string') properties = this.search(properties);
		var from = {}, to = {};
		for (var p in properties){
			var parsed = this.prepare(this.element, p, properties[p]);
			from[p] = parsed.from;
			to[p] = parsed.to;
		}
		return this.parent(from, to);
	}

});

Element.Properties.morph = {

	set: function(options){
		this.get('morph').cancel().setOptions(options);
		return this;
	},

	get: function(){
		var morph = this.retrieve('morph');
		if (!morph){
			morph = new Fx.Morph(this, {link: 'cancel'});
			this.store('morph', morph);
		}
		return morph;
	}

};

Element.implement({

	morph: function(props){
		this.get('morph').start(props);
		return this;
	}

});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/mootools-core/Source/Fx/Fx.Morph.js
lsd_rails-0.1.5 Packages/mootools-core/Source/Fx/Fx.Morph.js
lsd_rails-0.1.4 Packages/mootools-core/Source/Fx/Fx.Morph.js
lsd_rails-0.1.3 Packages/mootools-core/Source/Fx/Fx.Morph.js
lsd_rails-0.1.2 Packages/mootools-core/Source/Fx/Fx.Morph.js
lsd_rails-0.1.1 Packages/mootools-core/Source/Fx/Fx.Morph.js
lsd_rails-0.1 Packages/mootools-core/Source/Fx/Fx.Morph.js