From e5bb0889cd5bcd9123a74cf76f84e8ef60eacf9c Mon Sep 17 00:00:00 2001 From: Kris Borchers Date: Thu, 1 Aug 2013 23:24:29 -0500 Subject: [PATCH 1/2] Update everything that can't be polyfilled in old IE. Replace PointerMap.size getter with a size method. Quote properties named delete. --- src/capture.js | 2 +- src/mouse.js | 2 +- src/ms.js | 2 +- src/touch.js | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/capture.js b/src/capture.js index 464e7724..e07b45e5 100644 --- a/src/capture.js +++ b/src/capture.js @@ -32,7 +32,7 @@ dispatcher.releaseCapture(pointerId, this); }; } - if (!Element.prototype.setPointerCapture) { + if (window.Element && !Element.prototype.setPointerCapture) { Object.defineProperties(Element.prototype, { 'setPointerCapture': { value: s diff --git a/src/mouse.js b/src/mouse.js index 9601eb23..e7138b7e 100644 --- a/src/mouse.js +++ b/src/mouse.js @@ -94,7 +94,7 @@ this.cleanupMouse(); }, cleanupMouse: function() { - pointermap.delete(this.POINTER_ID); + pointermap['delete'](this.POINTER_ID); } }; diff --git a/src/ms.js b/src/ms.js index 7d0c3564..f35f888f 100644 --- a/src/ms.js +++ b/src/ms.js @@ -41,7 +41,7 @@ return e; }, cleanup: function(id) { - pointermap.delete(id); + pointermap['delete'](id); }, MSPointerDown: function(inEvent) { pointermap.set(inEvent.pointerId, inEvent); diff --git a/src/touch.js b/src/touch.js index 0a5c45de..24768ac3 100644 --- a/src/touch.js +++ b/src/touch.js @@ -54,11 +54,11 @@ } }, elementRemoved: function(el) { - this.scrollType.delete(el); + this.scrollType['delete'](el); dispatcher.unlisten(el, this.events); // remove touch-action from shadow allShadows(el).forEach(function(s) { - this.scrollType.delete(s); + this.scrollType['delete'](s); dispatcher.unlisten(s, this.events); }, this); }, @@ -291,7 +291,7 @@ this.cleanUpPointer(inPointer); }, cleanUpPointer: function(inPointer) { - pointermap.delete(inPointer.pointerId); + pointermap['delete'](inPointer.pointerId); this.removePrimaryPointer(inPointer); }, // prevent synth mouse events from creating pointer events From adfbfd5ef366b5cc17e34a0adcdfad6e752282c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 10 Oct 2013 09:39:15 -0400 Subject: [PATCH 2/2] Added support for external hooks for event binding and dispatching. --- src/boot.js | 1 + src/dispatcher.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/boot.js b/src/boot.js index c6d552b4..f0226591 100644 --- a/src/boot.js +++ b/src/boot.js @@ -6,6 +6,7 @@ (function(scope) { scope = scope || {}; + scope.external = scope.external || {}; var target = { shadow: function(inEl) { if (inEl) { diff --git a/src/dispatcher.js b/src/dispatcher.js index 058fcdc4..7d11d239 100644 --- a/src/dispatcher.js +++ b/src/dispatcher.js @@ -131,6 +131,9 @@ es.unregister.call(es, element); } }, + contains: scope.external.contains || function(container, contained) { + return container.contains(contained); + }, // EVENTS down: function(inEvent) { this.fireEvent('pointerdown', inEvent); @@ -161,13 +164,13 @@ this.fireEvent('pointercancel', inEvent); }, leaveOut: function(event) { - if (!event.target.contains(event.relatedTarget)) { + if (!this.contains(event.target, event.relatedTarget)) { this.leave(event); } this.out(event); }, enterOver: function(event) { - if (!event.target.contains(event.relatedTarget)) { + if (!this.contains(event.target, event.relatedTarget)) { this.enter(event); } this.over(event); @@ -199,10 +202,10 @@ this.removeEvent(target, e); }, this); }, - addEvent: function(target, eventName) { + addEvent: scope.external.addEvent || function(target, eventName) { target.addEventListener(eventName, this.boundHandler); }, - removeEvent: function(target, eventName) { + removeEvent: scope.external.removeEvent || function(target, eventName) { target.removeEventListener(eventName, this.boundHandler); }, // EVENT CREATION AND TRACKING @@ -282,7 +285,7 @@ * @param {Event} inEvent The event to be dispatched. * @return {Boolean} True if an event handler returns true, false otherwise. */ - dispatchEvent: function(inEvent) { + dispatchEvent: scope.external.dispatchEvent || function(inEvent) { var t = this.getTarget(inEvent); if (t) { return t.dispatchEvent(inEvent);