Fixed a grammatical error in Element.Event (build-in to built-in
[mootools.git] / Docs / Fx / Fx.Morph.md
blob2c02662c400a659d9a41aeab9368054ae84d082f
1 Class: Fx.Morph {#Fx-Morph}
2 ===========================
4 Allows for the animation of multiple CSS properties at once, even by a CSS selector. Inherits methods, properties, options and events from [Fx][].
6 ### Extends:
8 - [Fx][]
10 ### Syntax:
12         var myFx = new Fx.Morph(element[, options]);
14 ### Arguments:
16 1. element - (*mixed*) A string ID of the Element or an Element to apply the style transitions to.
17 2. options - (*object*, optional) The [Fx][] options object.
19 ### Returns:
21 * (*object*) A new Fx.Morph instance.
23 ### Examples:
25 Multiple styles with start and end values using an object:
27         var myEffect = new Fx.Morph('myElement', {duration: 'long', transition: Fx.Transitions.Sine.easeOut});
29         myEffect.start({
30                 'height': [10, 100], //Morphs the 'height' style from 10px to 100px.
31                 'width': [900, 300]  //Morphs the 'width' style from 900px to 300px.
32         });
35 Multiple styles with the start value omitted will default to the current Element's value:
37         var myEffect = new Fx.Morph('myElement', {duration: 'short', transition: Fx.Transitions.Sine.easeOut});
39         myEffect.start({
40                 'height': 100, //Morphs the height from the current to 100px.
41                 'width': 300   //Morphs the width from the current to 300px.
42         });
45 Morphing one Element to match the CSS values within a CSS class:
47         var myEffect = new Fx.Morph('myElement', {duration: 1000, transition: Fx.Transitions.Sine.easeOut});
49         // the styles of myClassName will be applied to the target Element.
50         myEffect.start('.myClassName');
53 ### See Also:
55 - [Fx][]
59 Fx.Morph Method: set {#Fx-Morph:set}
60 ------------------------------------
62 Sets the Element's CSS properties to the specified values immediately.
64 ### Syntax:
66         myFx.set(to);
68 ### Arguments:
70 1. properties - (*mixed*) Either an *object* of key/value pairs of CSS attributes to change or a *string* representing a CSS selector which can be found within the CSS of the page.  If only one value is given for any CSS property, the transition will be from the current value of that property to the value given.
72 ### Returns:
74 * (*object*) This Fx.Morph instance.
76 ### Examples:
78         var myFx = new Fx.Morph('myElement').set({
79                 'height': 200,
80                 'width': 200,
81                 'background-color': '#f00',
82                 'opacity': 0
83         });
84         var myFx = new Fx.Morph('myElement').set('.myClass');
88 Fx.Morph Method: start {#Fx-Morph:start}
89 ----------------------------------------
91 Executes a transition for any number of CSS properties in tandem.
93 ### Syntax:
95         myFx.start(properties);
97 ### Arguments:
99 1. properties - (*mixed*) An *object* of key/value pairs of CSS attributes to change or a *string* representing a CSS selector which can be found within the CSS of the page.
100         If only one value is given for any CSS property, the transition will be from the current value of that property to the value given.
102 ### Returns:
104 * (*object*) This Fx.Morph instance.
106 ### Examples:
108         var myEffects = new Fx.Morph('myElement', {duration: 1000, transition: Fx.Transitions.Sine.easeOut});
110         myEffects.start({
111                 'height': [10, 100],
112                 'width': [900, 300],
113                 'opacity': 0,
114                 'background-color': '#00f'
115         });
117 ### Notes:
119 - If a string is passed as the CSS selector, the selector must be identical to the one within the CSS.
120 - Multiple selectors (with commas) are not supported.
123 Object: Element.Properties {#Element-Properties}
124 ==============================================
126 see [Element.Properties][]
128 Element Property: morph {#Element-Properties:morph}
129 ---------------------------------------------------
131 ### Setter
133 Sets a default Fx.Morph instance for an Element.
135 #### Syntax:
137         el.set('morph'[, options]);
139 #### Arguments:
141 1. options - (*object*, optional) The Fx.Morph options.
143 #### Returns:
145 * (*element*) This Element.
147 #### Examples:
149         el.set('morph', {duration: 'long', transition: 'bounce:out'});
150         el.morph({height: 100, width: 100});
152 ### Getter
154 Gets the default Fx.Morph instance for the Element.
156 #### Syntax:
158         el.get('morph');
160 #### Arguments:
162 1. property - (*string*) the Fx.Morph property argument.
164 #### Returns:
166 * (*object*) The Fx.Morph instance.
168 #### Examples:
170         el.set('morph', {duration: 'long', transition: 'bounce:out'});
171         el.morph({height: 100, width: 100});
172         el.get('morph'); // the Fx.Morph instance.
176 Type: Element {#Element}
177 ==========================
179 Element Method: morph {#Element:morph}
180 --------------------------------------
182 Animates an Element given the properties passed in.
184 ### Syntax:
186         myElement.morph(properties);
188 ### Arguments:
190 1. properties - (*mixed*) The CSS properties to animate. Can be either an object of CSS properties or a string representing a CSS selector.  If only one value is given for any CSS property, the transition will be from the current value of that property to the value given.
192 ### Returns:
194 * (*element*) This Element.
196 ### Example:
198 With an object:
200         $('myElement').morph({height: 100, width: 200});
202 With a selector:
204         $('myElement').morph('.class1');
206 ### See Also:
208 - [Fx.Morph][]
212 [$]: /core/Element/Element#Window:dollar
213 [Fx]: /core/Fx/Fx
214 [Fx.Morph]: #Fx-Morph
215 [Element.Properties]: /core/Element/Element/#Element-Properties