MCPcopy Create free account
hub / github.com/dcloudio/mui / dispatchEvent

Function dispatchEvent

js/mui.fixed.fastclick.js:32–48  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

30 target: false
31 });
32 var dispatchEvent = function(event) {
33 var targetElement = $.targets.click;
34 if (targetElement) {
35 var clickEvent, touch;
36 // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect
37 if (document.activeElement && document.activeElement !== targetElement) {
38 document.activeElement.blur();
39 }
40 touch = event.detail.gesture.changedTouches[0];
41 // Synthesise a click event, with an extra attribute so it can be tracked
42 clickEvent = document.createEvent('MouseEvents');
43 clickEvent.initMouseEvent('click', true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
44 clickEvent.forwardedTouchEvent = true;
45 targetElement.dispatchEvent(clickEvent);
46 event.detail && event.detail.gesture.preventDefault();
47 }
48 };
49 window.addEventListener('tap', dispatchEvent);
50 window.addEventListener('doubletap', dispatchEvent);
51 //捕获

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected