Contains Fx.Tween and the Element shortcut Element.tween.
The Tween effect, used to transition any CSS property from one value to another.
var myFx = new Fx.Tween(element, [, options]);
Tweens the height of a element while clicking a link (which stops the default behavior), using a transition and a long duration.
It uses the link
option so when clicking the link twice it behaves smoothly. When the start value is omitted, the current
value of the property (in this example the height property) will be used.
var myFx = new Fx.Tween('myElement', { duration: 'long', transition: 'bounce:out', link: 'cancel', property: 'height' }); document.id('myLink').addEvent('click', function(event){ event.stop(); myFx.start(40, 100); });
It is also possible to use the Element properties: .get('tween')
and .set('tween')
and the tween
method.
In this example the property method is not set as an option, now it should be set as argument of the tween
method.
This is something you can choose for both the Fx.Tween
constructor or this approach.
var myElement = document.id('myElement'); myElement.set('tween', { duration: 'long', transition: 'bounce:out', link: 'cancel' }); document.id('myLink').addEvent('click', function(event){ event.stop(); myElement.tween('height', 40, 100); });
Sets the Element's CSS property to the specified value immediately.
myFx.set(property, value);
var myFx = new Fx.Tween(element); // sets the background color of the element to red: myFx.set('background-color', '#f00');
If you use the property option, you must not use the property argument in the start and set methods.
Transitions the Element's CSS property to the specified value.
myFx.start([property,] [from,] to);
var myFx = new Fx.Tween(element); // transitions the background color of the Element from black to red: myFx.start('background-color', '#000', '#f00'); // transitions the background color of the Element from its current color to blue: myFx.start('background-color', '#00f');
Sets and gets default options for the Fx.Tween instance of an Element.
el.set('tween'[, options]);
el.set('tween', {duration: 'long'}); el.tween('color', '#f00');
el.get('tween');
el.get('tween').start(0);
Custom Type to allow all of its methods to be used with any DOM element via the dollar function $.
Element shortcut method which immediately transitions any single CSS property of an Element from one value to another.
myElement.tween(property, startValue[, endValue]);
// transitions the width of 'myElement' from its current width to 100px: $('myElement').tween('width', '100'); // transitions the height of 'myElement' from 20px to 200px: $('myElement').tween('height', [20, 200]); // transitions the border of 'myElement' from its current to '6px solid blue': $('myElement').tween('border', '6px solid #36f');
Element shortcut method for tween with opacity. Useful for fading an Element in and out or to a certain opacity level.
myElement.fade([how]);
$('myElement').fade('out'); // fades 'myElement' out. $('myElement').fade(0.7); // fades 'myElement' to 70% opacity.
Element shortcut method for tweening the background color. Immediately transitions an Element's background color to a specified highlight color then back to its set background color.
myElement.highlight([start, end]);
If no background color is set on the Element, or its background color is set to 'transparent', the default end value will be white.
//immediately changes the background to light blue, then back to its original color (or white): $('myElement').highlight('#ddf'); //immediately changes the background to light blue, then fades to grey: $('myElement').highlight('#ddf', '#ccc');
© Linux.ria.ua, 2008-2024 |