BillyRayPreachersSon
Programmer
Has anyone had any luck changing the duration that a scriptaculous effect takes - while the effect is in progress?
I tried the following, but it appears not to work, jumping to the end of the effect pretty much immediately.
For example, if I use an initial duration of 2.0, and then call this with 5.0 before halfway through the effect, the effect ends instead of carrying on for longer.
My guess is that the effect is picking up on some of the changes before all have had a chance to be set.
This is the code I'm using:
Thanks,
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
I tried the following, but it appears not to work, jumping to the end of the effect pretty much immediately.
For example, if I use an initial duration of 2.0, and then call this with 5.0 before halfway through the effect, the effect ends instead of carrying on for longer.
My guess is that the effect is picking up on some of the changes before all have had a chance to be set.
This is the code I'm using:
Code:
function changeEffectSpeed: function(newSpeed) {
var queue = Effect.Queues.get('queueName');
queue.each(function(theEffect) {
var percentageThroughEffect = theEffect.currentFrame / theEffect.totalFrames;
// Copied from Effect.Base
theEffect.options.duration = newSpeed;
theEffect.startOn = theEffect.options.delay * 1000;
theEffect.finishOn = theEffect.startOn + (theEffect.options.duration * 1000);
theEffect.fromToDelta = theEffect.options.to - theEffect.options.from;
theEffect.totalTime = theEffect.finishOn - theEffect.startOn;
theEffect.totalFrames = theEffect.options.fps * theEffect.options.duration;
// Now set the current frame based upon the new duration
theEffect.currentFrame = theEffect.totalFrames * percentageThroughEffect;
});
}
Thanks,
Dan
Coedit Limited - Delivering standards compliant, accessible web solutions
[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]