With no pre-calculations, this is about what we get:
onmousemove, with custom object: 10000 events in 4350 milliseconds
onmousemove, with native object: 10000 events in 3201 milliseconds
1.358950328022493

I added prototype.stopPropagation and .preventDefaut, .stop now calls both of these methods.

The new iteration will look something like:

MochiKit.Signal.Event.prototype.repr = function () {
    var repr = MochiKit.Base.repr;
    var str = '{event: ' + repr(this.event()) +
        ', type(): ' + repr(this.type()) +
        ', target(): ' + repr(this.target()) +
        ', modifier(): ' + '{alt: ' + repr(this.modifier().alt) +
        ', ctrl: ' + repr(this.modifier().ctrl) +
        ', meta: ' + repr(this.modifier().meta) +
        ', shift: ' + repr(this.modifier().shift) + '}';

    if (this.type() && this.type().indexOf('key') === 0) {
        str += ', key(): {code: ' + repr(this.key().code) +
            ', string: ' + repr(this.key().string) + '}';
    }

    if (this.type() && (
        this.type().indexOf('mouse') === 0 ||
        this.type().indexOf('click') != -1 ||
        this.type() == 'contextmenu')) {

        str += ', mouse(): {cursor(): ' + repr(this.mouse().cursor);

        if (this.type() != 'mousemove') {
str += ', button(): {left: ' + repr(this.mouse ().button.left) +
                ', middle: ' + repr(this.mouse().button.middle) +
                ', right: ' + repr(this.mouse().button.right) + '}';
        }
    }

    if (this.type() == 'mouseover' || this.type() == 'mouseout') {
str += ', relatedTarget(): ' + repr(this.relatedTarget()) + '}';
    }

    return str;
};


I think that it's reasonable to allow the user to generate their own timestamp upon event receipt. Most use cases (I'd say 99%) don't require one, and it's trivial to synthesize one in the use cases that do.

Reply via email to