mootools/mootools-core — Issue #2315: Custom Events on type 1 events do not call condition
Author: somethingkindawierd
Created: 2012-02-27 17:08:03+00:00
State: open

Creating custom Event definitions for type 1 events, such as scroll, does not call the custom event condition.

Example, here's a jsfiddle of what I wanted to do and you can see the condition never get's called, so the event always fires.

http://jsfiddle.net/somethingkindawierd/5RTZ5/3/

Forcefully overriding the event type to 2 gets around the issue, but is not ideal for performance reasons.

If this is by design, fine, but if not, the fix is rather simple. In Element.Event.js, about line 44, we see this:

```
var defn = function(){
return fn.call(self);
};
```

If changed to this, then the custom condition will run for type 1 events:

```
var defn = function(){
if (condition.call(self, event) === false) event.stop();
};
```