Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Whitelist Selector #504

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Whitelist Selector #504

wants to merge 4 commits into from

Conversation

davidofwatkins
Copy link

This adds support to opt-in to FastClick for elements matching a specified query selector. Instead of using .needsclick everywhere, FastClick can now apply itself only to elements matching .fastclick, for example:

FastClick.attach(document.body, {
    // only enable for elements with the .fastlcick class and their children
    selector: '.fastclick, .fastclick *'
});
<a>Ignored by FastClick</a>
<a class="fastclick">Uses FastClick</a>

I was previously using SelectiveFastclick to handle this, but it was causing some problems with scrolling on iOS, and it didn't make much sense to me to have the overhead of an entirely separate project for what should be a small feature.

Here are some GitHub issues that this may address:

Unfortunately, browser support for this is a bit more limited than FastClick, itself, so I've noted that in the README. This may be a deal-breaker (it wasn't for me), so hopefully this PR is at least helpful to someone even if it's not fully ready to merge.

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

Successfully merging this pull request may close these issues.

1 participant