new Animate(el [, settings])
- Easily animate CSS values. credit
- The following easing options are available:
linear,elastic,quad,quint,circ,backorbounce. - You can animate relative values by doing
+25or-25for a value. Which will take the current property value and increase or decrease the property balue by 25 (see demo). - The
tomenthod is used to animate css values and override global configuration. - The
delaymethod is used to delay the animation from occuring. - See it in action + some notes! 😀
Parameters:
| Name | Type | Argument | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
el |
HTMLElement | Element to animate. |
||||||||||||||||
settings |
Object |
<optional> |
Global configuration settings. Properties
|
Example
// Global configuration
var settings = {duration: 500, easing: 'bounce'};
var animation = new ML.Animate(ML.El.$q('#el'), settings);
animation.to({ width: 100 }, {}, function() {
console.log('animation complete');
})
Methods
-
delay(time)
-
Delays animating the element.
Parameters:
Name Type Description timeNumber The amount of time to delay the animation, in ms.
-
to(props [, settings] [, cb])
-
Animate element.
Parameters:
Name Type Argument Description propsObject CSS properties to animate.
settingsObject <optional>
Override Global Configuration settings.
Properties
Name Type Argument Default Description durationNumber <optional>
200 The duration of the animation, defaults to 400ms.
easingString <optional>
linear Type of animation (
bounce,elastic, etc..), defaults tolinearcbfunction <optional>
Callback function.