script.aculo.us---Core Effects

The six [b] [color=red]core effects[/color] [/b][b]Effect.Opacity, Effect.Scale, Effect.Morph, Effect.Move, Effect.Highlight and Effect.Parallel [/b]are the foundation of the script.aculo.us [b]Visual Effects[/b] Java Script library.

Syntax
The basic syntax to start an effect is:
  new Effect.EffectName( element, required-params, [options] );

Common parameters [b]通用参数[/b]
All core effects support following settings in their options parameter:所有[b]核心效果[/b]都支持这些参数!V1.0代表支持的版本

Option since Description
[b]duration [/b]V1.0 Duration of the effect in seconds, given as a float. Defaults to 1.0.
[b]fps[/b] V1.0 Target this many frames per second. Default to 25. Can’t be higher than 100.
[b]transition[/b] V1.0 Sets a function that modifies the current point of the animation, which is between 0 and 1. Following transitions are supplied: Effect.Transitions.sinoidal (default), Effect.Transitions.linear, Effect.Transitions.reverse, Effect.Transitions.wobble and Effect.Transitions.flicker.
[b]from[/b] V1.0 Sets the starting point of the transition, a float between 0.0 and 1.0. Defaults to 0.0.
[b]to [/b]V1.0 Sets the end point of the transition, a float between 0.0 and 1.0. Defaults to 1.0.
[b]sync[/b] V1.0 Sets whether the effect should render new frames automatically (which it does by default). If true, you can render frames manually by calling the render() instance method of an effect. This is used by Effect.Parallel().
[b]queue[/b] V1.5 Sets queuing options. When used with a string, can be ‘front’ or ‘end’ to queue the effect in the global effects queue at the beginning or end, or a queue parameter object that can have {position:’front/end’, scope:’scope’, limit:1}. For more info on this, see Effect Queues.
[b]delay[/b] V1.5 Sets the number of seconds to wait before the effect actually starts. Defaults to 0.0.
[b]direction[/b] ?? Sets the direction of the transition. Values can be either ‘top-left’, ‘top-right’, ‘bottom-left’, ‘bottom-right’ or ‘center’ (Default). Applicable only on Grow and Shrink effects.


Additionally, the options parameter also can be supplied with callback methods, so you can have Java Script executed at various events while the effect is running. The callbacks are supplied with a reference to the effect object as a parameter. Here is an example of getting the element id passed by reference into a callback function:

Callback since Description
[b]beforeStart[/b] V1.0 Called before the main effects rendering loop is started.
[b]beforeUpdate[/b] V1.0 Called on each iteration of the effects rendering loop, before the redraw takes places.
[b]afterUpdate[/b] V1.0 Called on each iteration of the effects rendering loop, after the redraw takes places.
[b]afterFinish[/b] V1.0 Called after the last redraw of the effect was made.

Within the effect object, there are several useful variables you can access:

Variable since Description
[b]effect.element [/b]V1.0 The element the effect is applied to.
[b]effect.options[/b] V1.0 Holds the options you gave to the effect.
[b]effect.currentFrame[/b] V1.0 The number of the last frame rendered.
[b]effect.startOn, effect.finishOn [/b]V1.0 The times (in ms) when the effect was started, and when it will be finished.
[b]effect.effects[][/b] V1.0 On an Effect.Parallel effect, there’s an effects[] array containing the individual effects the parallel effect is composed of.

Example usage of Callback functions

function myCallBackOnFinish(obj){
alert("the Element's id the effect was applied to is :" + obj.element.id);
}
function myCallBackOnStart(obj){
alert("the Element object the effect will be applied to is :" + obj.element);
}
new Effect.Highlight(myObject,
{ startcolor:'#ffffff',
endcolor:'#ffffcc',
duration: 0.5,
afterFinish: myCallBackOnFinish,
BeforeStart: myCallBackOnStart });


[url]http://wiki.script.aculo.us/scriptaculous/show/CoreEffects[/url]
Effects Treasure Chest 更多效果百宝箱?
[url]http://wiki.script.aculo.us/scriptaculous/show/EffectsTreasureChest[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值