From 4139dc277804e295e2571a7d8bf3e213f88cd6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Rodr=C3=ADguez?= Date: Thu, 26 Jun 2014 10:03:37 +0200 Subject: [PATCH] Cancel pointer-event:none effects in some elements Added a new option (cancel) --- pointer_events_polyfill.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pointer_events_polyfill.js b/pointer_events_polyfill.js index e9d751a..76cd4b5 100644 --- a/pointer_events_polyfill.js +++ b/pointer_events_polyfill.js @@ -8,6 +8,7 @@ function PointerEventsPolyfill(options){ // set defaults this.options = { selector: '*', + cancel: '', mouseEvents: ['click','dblclick','mousedown','mouseup'], usePolyfillIf: function(){ if(navigator.appName == 'Microsoft Internet Explorer') @@ -43,7 +44,8 @@ PointerEventsPolyfill.initialize = function(options){ // handle mouse events w/ support for pointer-events: none PointerEventsPolyfill.prototype.register_mouse_events = function(){ // register on all elements (and all future elements) matching the selector - $(document).on(this.options.mouseEvents.join(" "), this.options.selector, function(e){ + $(document).on(this.options.mouseEvents.join(" "), this.options.selector, {cancel: this.options.cancel}, function(e){ + if($(e.originalEvent.srcElement).closest(e.data.cancel).length > 0) return true; if($(this).css('pointer-events') == 'none'){ // peak at the element below var origDisplayAttribute = $(this).css('display');