new UWA.Fx(element, options)
Simple cross-platform API for DOM elements animation/effects.
Available Events
| Event | Description |
|---|---|
onStart |
Triggered when the animation starts |
onAnimate |
Triggered on each animation frame |
onComplete |
Triggered when the animation ends |
Example
// Create the element to animate
var myElement = UWA.createElement('div');
// Initialize FX with myElement and some options
var fx = new UWA.Fx(myElement, {
duration: 250,
transition: 'bounceIn',
events: {
onStart: function () {
// Callback trigered when the animation starts
},
onAnimate: function () {
// Callback trigered on each animation frame
},
onComplete: function () {
// Callback trigered when the animation ends
}
}
});
// Run Fx from a range to another
fx.start({
backgroundColor: ['#FF0000', '#0000FF'],
padding: [10, 20],
height: [10, 200],
width: [10, 200],
opacity: [0, 1]
});
// Run Fx from current values to new one
fx.start({
backgroundColor: '#FF0000',
padding: 10,
height: 10,
width: 10,
opacity: 0
});
// OR
fx.fade();
// OR
fx.tween('color', '#0000FF', '#FF0000');
Parameters
| Name | Type | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
Element | A valid DOM element |
|||||||||||||||||||||||||
options |
Object | Options hash or a option/value pair. Properties
|
Mixes In
- UWA.Class.Options
- UWA.Class.Timed
- UWA.Class.Events
Index
Members
Methods
Members
-
defaultOptions
-
The default options values.
-
element
-
The current element affected by animation.
-
from
-
The animation initial values.
-
to
-
The animation final values.
-
current
-
The animation current values.
-
<static> Transitions :Object
-
A collection of tweening transitions for use with the UWA.Fx classes.
Type
- Object
- See:
- To Do:
-
- http://greweb.me/2012/02/bezier-curve-based-easing-functions-from-concept-to-implementation/
- http://www.greensock.com/customease/
Properties:
Name Type Description linearFunction Displays a linear transition
quadInFunction Displays a quadratic transition in
quadOutFunction Displays a quadratic transition out
quadInOutFunction Displays a quadratic transition in and out
cubicInFunction Displays a cubicular transition in
cubicOutFunction Displays a cubicular transition out
cubicInOutFunction Displays a cubicular transition in and out
quartInFunction Displays a quartetic transition in
quartOutFunction Displays a quartetic transition out
quartInOutFunction Displays a quartetic transition in and out
quintInFunction Displays a quintic transition in
quintOutFunction Displays a quintic transition out
quintInOutFunction Displays a quintic transition in and out
sineInFunction Displays a sineousidal transition in
sineOutFunction Displays a sineousidal transition out
sineInOutFunction Displays a sineousidal transition in and out
expoInFunction Displays a exponential transition in
expoOutFunction Displays a exponential transition out
expoInOutFunction Displays a exponential transition in and out
circInFunction Displays a circular transition in
circOutFunction Displays a circular transition out
circInOutFunction Displays a circular transition in and out
backInFunction Makes the transition go back in
backOutFunction Makes the transition go back out
backInOutFunction Makes the transition go back, then all forth
elasticInFunction Makes the transition as elastic curve in
elasticOutFunction Makes the transition as elastic curve out
elasticInOutFunction Makes the transition as elastic curve in and out
bounceInFunction Makes the transition bouncy in
bounceOutFunction Makes the transition bouncy out
bounceInOutFunction Makes the transition bouncy in and out
Methods
-
tween(property, from, to) → {this}
-
Start the animation of one CSS property.
Parameters
Name Type Description propertyString The css property to set the value to
fromString The css property value to set at start
toString The css property value to set at the end
Returns
- Type
- this
-
fade(how) → {this}
-
Element shortcut method for tween with opacity. Useful for fading an Element in and out or to a certain opacity level.
Parameters
Name Type Description howString The opacity level as a number or string representation. Possible values include:
inFade the element to 100% opacity.outFade the element to 0% opacity.showImmediately set the element's opacity to 100%.hideImmediately set the element's opacity to 0%.toggleIf visible, fade the element out, otherwise, fade it in.(float)A float value between 0 and 1. Will fade the element to this opacity.
Returns
- Type
- this
-
start(properties) → {this}
-
Start the animation of multiple CSS properties at once.
Parameters
Name Type Description propertiesObject 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.
Returns
- Type
- this
-
pause() → {this}
-
Pause the current animation.
Returns
- Type
- this
-
stop() → {this}
-
Stop the current animation and clear next steps.
Returns
- Type
- this
-
setSteps(properties)
-
Populate
toandfrombased on the properties parameter.Parameters
Name Type Description propertiesObject 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.
-
compute(from, to) → {Number}
-
Compute the step value using from, to parameters, transition options, currentTime and duration.
Parameters
Name Type Description fromNumber The start value
toNumber The end value
Returns
Computed value result.
- Type
- Number
-
animate()
-
Run the animation steps loop.
-
onAnimate(element, from, to)
-
Called on each step of the animation in order to perform the animation step on the element using <compute> on the to and from parameters properties value pair to get the current value of the properties to animate.
Parameters
Name Type Description elementElement The element attached
fromNumber The start value
toNumber The end value