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

Making it possible to distinguish touch/mouse as source of focus #155

Open
darobin opened this issue Jan 30, 2017 · 3 comments
Open

Making it possible to distinguish touch/mouse as source of focus #155

darobin opened this issue Jan 30, 2017 · 3 comments

Comments

@darobin
Copy link

darobin commented Jan 30, 2017

Right now data-focus-source makes it possible to tell keyboard from pointer as the source of focus. We (@halmos and I) would like to be able to further distinguish different types of pointers. The use case is to be able to provide a thicker (or otherwise more visible) focus outline on touch, because you can't see what's under your finger.

In terms of how this gets exposed, I don't think we can change data-focus-source without breaking compatibility. So that would always reflect "pointer". But we can add a second data attribute, say data-pointer-type, that could contain touch/mouse/stylus/catpaw/headbang/etc.

In terms of implementation, just giving it a quick look I believe that https://github.com/medialize/ally.js/blob/master/src/observe/interaction-type.js could expose that distinction (since it knows what event it's reacting to) by incrementing/decrementing modality-specific counters in addition to the pointer one, and then that https://github.com/medialize/ally.js/blob/master/src/style/focus-source.js#L52 could simply make use of that information.

We're open to other approaches of course, this is just what we've thought up. If you're up for this, we'd be happy to file a PR.

@rodneyrehm
Copy link
Member

I like your approach! Much simpler than what I had in mind.

I think I'd call the attribute data-focus-source-pointer="<value>". And <value> would returned by observe/interaction-type as a third property called pointerType, with its value defined by event.pointerType. I assume there's no mix'n'match, so modality-specific counters don't seem necessary. <value> would default to null, be "touch" for event.type === "touchstart", "mouse" for event.type === "mousedown" and otherwise whatever event.pointerType returns.

of course I'd love a PR for this :)

@alexanderbrown21
Copy link

how is this going looking into this?

@rodneyrehm
Copy link
Member

I'm not aware anyone has put work into this yet. Are you up for it?

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

No branches or pull requests

3 participants