I was hoping there's a more MooToolish way :-)

O.

On Mar 28, 2012, at 8:19 PM, Dimitar Christoff wrote:

> On 28 March 2012 19:01,  <[email protected]> wrote:
>> The documentation states "Fx Method: set: The set method is fired on every
>> step of a transition...".
>> 
>> Is this really the case? What would be the real-life example?
>> 
>> What I need is to fetch and print the current animation step, on every step.
>> 
>> Ideas?
>> 
> 
> why not hack Fx.prototype.step?
> 
> something like:
> 
> Fx.prototype.step = function(now) {
>    var props;
>    if (this.options.frameSkip) {
>        var diff = (this.time != null) ? (now - this.time) : 0,
>            frames = diff / this.frameInterval;
>        this.time = now;
>        this.frame += frames;
>    } else {
>        this.frame++;
>    }
> 
>    if (this.frame < this.frames) {
>        var delta = this.transition(this.frame / this.frames);
>        this.set(props = this.compute(this.from, this.to, delta));
>    } else {
>        this.frame = this.frames;
>        this.set(props = this.compute(this.from, this.to, 1));
>        this.stop();
>    }
>    this.fireEvent("step", [now, props]);
> };
> 
> document.id("foo").set("tween", {
>    duration: 1000,
>    onStep: function(time, vals) {
>        console.log("timer", time, vals);
>    }
> }).fade(0);
> 
> you cannot attach to .set because individual implementations of the Fx
> class will override that anyway.
> http://jsfiddle.net/dimitar/B5sPB/
> 
> i think that this will seriously delay/impact the actual animations in
> older browsers.
> 
> 
> -- 
> Dimitar Christoff
> 
> "JavaScript is to JAVA what hamster is to ham"
> http://fragged.org/ - @D_mitar - https://github.com/DimitarChristoff

Reply via email to