开发者

optionals skipping of fx in mootools

开发者 https://www.devze.com 2022-12-14 16:11 出处:网络
Is there a simple way to skip all the fx, while still setting the values and calling the events. I figure开发者_如何学God out to set the fx duration options globally to 0 by doing

Is there a simple way to skip all the fx, while still setting the values and calling the events.

I figure开发者_如何学God out to set the fx duration options globally to 0 by doing

Fx.prototype.options.duration = 0

but this still doesn't solve my problem because it sill takes some minimal time which ends up in a lot of displaying errors.

what would be nice is something like

Fx.ENGINE = 'on' / 'off'
Fx.SPEED_MULTIPLYER = 1 ... 10


Well after a litte hacking I've found a solution myself...

$extend(Fx.Durations, { skip: 0 });
$extend(Fx.prototype.options, { skip: false, multiplier: 1 });
Fx.implement({
    step: function() {
        var time = $time();
        if ((time < this.time + (this.options.duration / this.options.multiplier)) && !this.options.skip){
            var delta = this.transition((time - this.time) / (this.options.duration / this.options.multiplier));
            this.set(this.compute(this.from, this.to, delta));
        } else {
            this.set(this.compute(this.from, this.to, 1));
            this.complete();
        }
    },
    startTimer: function(){
        if (this.timer) return false;
        this.time = $time() - this.time;
        this.step();
        this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);
        return true;
    }
});

There is now a skip options which allows you to skip the effect and a multiplier option to globally speed up / slow down the effect.

jim

0

精彩评论

暂无评论...
验证码 换一张
取 消