0

I've created a web application that works well with touch events and click events with their own respective handlers.

However, issues are encountered when moving to touch IE11. Touch works fine on other platforms. The mouse on IE11 works great. But if you use both a touch screen and IE11, then the touch events are wrapped as pointer events instead of touch events or click events.

Is there any way to just globally map pointer touch events to pre-defined touch events for the entire window/document? It seems that it is already doing this by default for click events in IE11...

I tried following code example as displayed here: JavaScript mapping touch events to mouse events

And ended up with:

if(window.PointerEvent)
{
    ...
    document.onpointerdown = function(e){
        var event = document.createEvent("TouchEvent");
        ...
    }
    ...
}

However, IE errors at document.crateEvent("TouchEvent") claiming that it is "not supported." However, the TouchEvent object is documented in IE as being supported: https://msdn.microsoft.com/en-us/subscriptions/dn792856(v=vs.85) as specified in http://www.w3.org/TR/touch-events/#list-of-touchevent-types

I've also tried changing it to

var event = document.createEvent("UIEvent");

which IE allows, but then does later not recognize

event.initTouchEvent(someParameters);

I'm starting to believe that IE11 doesn't support creation of touch events.

I've also seen talk about changing the .css files to include combinations of:

touch-action: none
ms-touch-action: none
pointer-events: none

but completely disabling touch tends to break the application in other ways that I was hoping to avoid.

Is there any way to fire touch events instead of Microsoft's pointer events?

Community
  • 1
  • 1
user1519665
  • 511
  • 5
  • 16
  • Are you trying to do it via desktop IE11 or via Metro IE11 –  Jun 17 '15 at 14:06
  • Technically, both. Both versions of IE11, as well as the windows 8.1 native webview (Visual Studio .jsproj application) appear to support/not support the same things here. – user1519665 Jun 17 '15 at 14:18

1 Answers1

0

I would say you're actually going about this the wrong way. There are several pollyfill libraries to map touch events to pointer events. HandJS and jQuery PEP are two well functioning examples. Given that the only modern browser that doesn't support pointer events at this time is Safari, that seems the better way to go (Who wants pointer events...).

cjbarth
  • 4,189
  • 6
  • 43
  • 62
  • Unfortunately, not all of the libraries I'm using agree with that. Many of them ignore pointer events altogether, or map functionality that is unwanted. In the end, I ended up changing their libraries myself and changing styling on the elements on as needed basis. – user1519665 Aug 08 '15 at 16:21