Skip to content
This repository was archived by the owner on Feb 11, 2021. It is now read-only.

Commit adfbfd5

Browse files
scottgonzalezkborchers
authored andcommitted
Added support for external hooks for event binding and dispatching.
1 parent e5bb088 commit adfbfd5

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/boot.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
(function(scope) {
88
scope = scope || {};
9+
scope.external = scope.external || {};
910
var target = {
1011
shadow: function(inEl) {
1112
if (inEl) {

src/dispatcher.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
es.unregister.call(es, element);
132132
}
133133
},
134+
contains: scope.external.contains || function(container, contained) {
135+
return container.contains(contained);
136+
},
134137
// EVENTS
135138
down: function(inEvent) {
136139
this.fireEvent('pointerdown', inEvent);
@@ -161,13 +164,13 @@
161164
this.fireEvent('pointercancel', inEvent);
162165
},
163166
leaveOut: function(event) {
164-
if (!event.target.contains(event.relatedTarget)) {
167+
if (!this.contains(event.target, event.relatedTarget)) {
165168
this.leave(event);
166169
}
167170
this.out(event);
168171
},
169172
enterOver: function(event) {
170-
if (!event.target.contains(event.relatedTarget)) {
173+
if (!this.contains(event.target, event.relatedTarget)) {
171174
this.enter(event);
172175
}
173176
this.over(event);
@@ -199,10 +202,10 @@
199202
this.removeEvent(target, e);
200203
}, this);
201204
},
202-
addEvent: function(target, eventName) {
205+
addEvent: scope.external.addEvent || function(target, eventName) {
203206
target.addEventListener(eventName, this.boundHandler);
204207
},
205-
removeEvent: function(target, eventName) {
208+
removeEvent: scope.external.removeEvent || function(target, eventName) {
206209
target.removeEventListener(eventName, this.boundHandler);
207210
},
208211
// EVENT CREATION AND TRACKING
@@ -282,7 +285,7 @@
282285
* @param {Event} inEvent The event to be dispatched.
283286
* @return {Boolean} True if an event handler returns true, false otherwise.
284287
*/
285-
dispatchEvent: function(inEvent) {
288+
dispatchEvent: scope.external.dispatchEvent || function(inEvent) {
286289
var t = this.getTarget(inEvent);
287290
if (t) {
288291
return t.dispatchEvent(inEvent);

0 commit comments

Comments
 (0)