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

'touch' detection is invalid #188

Closed
nichoth opened this issue Oct 12, 2022 · 4 comments
Closed

'touch' detection is invalid #188

nichoth opened this issue Oct 12, 2022 · 4 comments

Comments

@nichoth
Copy link

nichoth commented Oct 12, 2022

Using this on a laptop computer, and I have set

            anchors.options = {
                visible: 'touch'
            }

However, it is detecting that a laptop is a touch device. When I look at the source code and try some in the browser console, !!window.TouchEvent is returning true, which is here in the source code — https:/bryanbraun/anchorjs/blob/master/anchor.js#L52


example in use: https://nichoth.com/list/

nichoth added a commit to nichoth/anchorjs that referenced this issue Nov 14, 2022
@bryanbraun
Copy link
Owner

Thanks for the issue and PR. I hope to be able to take a closer look at this next week. 👍

@y377
Copy link

y377 commented Jan 10, 2023

For such an excellent plugin, I would like to share my demo, my touch can be used well! There are also hover prompts and one-click copy (he can jump to the anchor by clicking on it).
and thank you @bryanbraun

@bryanbraun
Copy link
Owner

Hey, @nichoth, thanks for reporting the issue.

This issue has come up before and been discussed in detail here: #168

In short, your fix addresses some common device use-cases but breaks others because there's no reliable way to detect a touchscreen. 😞

Ultimately, this touch feature is misleading and I plan to remove it entirely in a future version of AnchorJS.

My recommendation is that if you want the older behavior of this, you can use version 4.2.2 as described here.

@nichoth
Copy link
Author

nichoth commented Jan 14, 2023

Ok thanks for checking it out. I am using my fork currently, and that has been working for me.

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

3 participants