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

Does not work on devices with both mouse and touch screen #228

Open
kostyantin2216 opened this issue Dec 27, 2018 · 1 comment
Open

Does not work on devices with both mouse and touch screen #228

kostyantin2216 opened this issue Dec 27, 2018 · 1 comment

Comments

@kostyantin2216
Copy link

kostyantin2216 commented Dec 27, 2018

This library does not support devices with a mouse and a touch screen.

We are using a Windows 8 laptop with a touch screen, what happens is if we select dates or change months with the touch screen everything works fine but if we use the mouse nothing happens.

I looked into the source code and found inside util.js the addEvent function on line 77 has a conditional check which checks if the event type that is being registered is mousedown and if the device is a touch device, if it is then instead of registering mousedown it registers touchstart.

After reading up on touch events and comparing them to click events i saw that both touches and clicks emit one mousedown event, this can be seen here, so my question is if this check is even necessary? I might be missing something but shouldn't this work if we registered mousedown also for touch devices?

Here is the code snippet i am talking about:

if(eventName === 'mousedown' && util.isTouchDevice()) {
	//works on touch devices
	elem.addEventListener('touchstart', listener, false);
} else {
	elem.addEventListener(eventName, listener, false);
}
@Twipped
Copy link
Owner

Twipped commented Jan 18, 2019

I'm not sure if this is the case still, but the reason this was done back when Kalendae was created was because mouse events did not trigger at the same speed as touch events on touch devices. There was always a noticeable pause of about 300ms between when touch events fired and mouse events followed suit. This was done deliberately by webkit (which was the only mobile engine at the time) because of gesture detection. See https://www.sitepoint.com/5-ways-prevent-300ms-click-delay-mobile-devices/

This is a very old library, in internet time. It needs to be completely rewritten for a version 2.0, which would let the library dump IE support and remove a lot of unneeded cruft, but I've not had any reason to do that. If somebody wants to do a PR to add PointerEvents support, which would solve this problem in Edge, I'd be open to accepting it. It just needs to degrade gracefully in older browsers, since 1.x still officially supports IE8.

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

2 participants