简体   繁体   中英

optionals skipping of fx in mootools

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

I figured 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM