Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to click on inputs to focus #2

Open
nicinabox opened this issue Oct 29, 2014 · 6 comments
Open

Unable to click on inputs to focus #2

nicinabox opened this issue Oct 29, 2014 · 6 comments

Comments

@nicinabox
Copy link

Example: http://jsbin.com/vaduzimayo

@joefreeman
Copy link
Contributor

I came across this problem too. I think #4 fixes it.

@ezsper
Copy link

ezsper commented Sep 6, 2015

The ignoreTags didn't work for me on Chrome, I believe you should consider to wrap the ignoreTags option also on preventMouseEvents function, that did the trick for me. Notice that with the code changes bellow on your script, I don't even need to set ignoreTags, it just works as it is, at least on my needs.

function onMouse(touchType) {
        return function(ev) {
            // prevent mouse events
            if(
              (ev.type === 'mousedown' || ev.type === 'mouseup') &&
              ev.target.tagName !== "INPUT" &&
              ev.target.tagName !== "SELECT" &&
              ev.target.tagName !== "TEXTAREA" &&
              ev.target.tagName !== "BUTTON"
            ) {
              preventMouseEvents(ev);
            }

@PvanHengel
Copy link

I have the same issue...

@liyikun
Copy link

liyikun commented Jul 4, 2018

I have the same issue too!!!!!!!!!...

@ghost
Copy link

ghost commented Aug 13, 2018

I'm also having this issue.

@ghost
Copy link

ghost commented Jul 22, 2019

I have tested more scenarios and nowadays it's not working properly. Its not catching taps and swipes.
Anyone knows if it will have any update?

The best I came was this:

function touchHandler(event) {
	//var touch = event.changedTouches[0];
	var touch = event;
	var eventType = '#';
	if(event.type == 'mousedown') eventType = 'touchstart';
	else if(event.type == 'mousemove') eventType = 'touchmove';
	else if(event.type == 'mouseup') eventType = 'touchend';
	else if(event.type == 'mousecancel') eventType = 'touchcancel';
	//else if(event.type == 'click') eventType = 'touch';
	console.log(eventType);

	const touchObj = new Touch({
		identifier: Date.now(),
		target: touch.target,
		screenX: touch.screenX,
		screenY: touch.screenY,
		clientX: touch.clientX,
		clientY: touch.clientY,
		radiusX: 2.5,
		radiusY: 2.5,
		rotationAngle: 10,
		force: 0.5,
	  });

	  const touchEvent = new TouchEvent(eventType, {
		cancelable: true,
		bubbles: true,
		touches: [touchObj],
		targetTouches: [],
		changedTouches: [touchObj],
		shiftKey: true,
	  });

	touch.target.dispatchEvent(touchEvent);
	event.preventDefault();
}

function init() {
	document.addEventListener("mousedown", touchHandler, true);
	document.addEventListener("mousemove", touchHandler, true);
	document.addEventListener("mouseup", touchHandler, true);
	document.addEventListener("mousecancel", touchHandler, true);
	//document.addEventListener("click", touchHandler, true);
}

Greetings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants