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

Add Element.hasPointerCapture API #121

Closed
RByers opened this Issue Jul 28, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@RByers
Contributor

RByers commented Jul 28, 2016

As discussed at the hackathon, if we end up going with the reduced hit-test model (#8) then there may be scenarios where some library will want behave differently depending on whether the pointer has been captured, without actually changing the capture itself.

For example, some analytics libraries track "user attention" by recording a log of the position and interesting underlying elements of every pointer. If touch starts capturing implicitly, it's possible the stats from such a library could be broken. To mitigate this they might want to do their own elementFromPoint hit-test on pointermove without actually doing a releasePointerCapture.

Really this is a more generic problem that in composition scenarios one library may want to know if the pointer is currently captured or not. It's not clear how important this is, but it seems to make a lot of sense to have an API like Element.hasPointerCapture(pointerId) which pointer event listeners could check on the target of the event.

@RByers RByers added the v2-blocking label Jul 28, 2016

@RByers RByers self-assigned this Jul 28, 2016

@RByers

This comment has been minimized.

Show comment
Hide comment
@RByers

RByers Jul 29, 2016

Contributor

I think the precise definition of this should be (roughly): "if the pending pointer capture target override for this pointerId is set and equals the element on which this method was invoked, return true. Otherwise return false".

In particular, we want "pending" because:

  • Implicit capture should behave the same as an explicit capture in a pointerdown handler (eg. we want only one gotpointercapture event in the explicit capture case).
  • We want this API to be able to tell you that implicit capture has occurred

So that means it'll reflect any change via setPointerCapture as soon as it happens, potentially well ahead of the notifications seen by the got/lost events.

Sound right @NavidZ @mustaqahmed @patrickhlauke @scottgonzalez @teddink @jacobrossi?

Contributor

RByers commented Jul 29, 2016

I think the precise definition of this should be (roughly): "if the pending pointer capture target override for this pointerId is set and equals the element on which this method was invoked, return true. Otherwise return false".

In particular, we want "pending" because:

  • Implicit capture should behave the same as an explicit capture in a pointerdown handler (eg. we want only one gotpointercapture event in the explicit capture case).
  • We want this API to be able to tell you that implicit capture has occurred

So that means it'll reflect any change via setPointerCapture as soon as it happens, potentially well ahead of the notifications seen by the got/lost events.

Sound right @NavidZ @mustaqahmed @patrickhlauke @scottgonzalez @teddink @jacobrossi?

@NavidZ

This comment has been minimized.

Show comment
Hide comment
@NavidZ

NavidZ Jul 29, 2016

Member

That sounds good. One thing I couldn't quite understand was the usecase of this. Regarding the hit-testing on pointermove I believe they can always add move handlers to the document and then they will always get that pointermove and they can do their own hit-testing.
For the other scenario how would one library get that pointerId in the first place? I guess this is discussed in more detail during Hackathon but can you give a more concrete example that one might use this API?

Member

NavidZ commented Jul 29, 2016

That sounds good. One thing I couldn't quite understand was the usecase of this. Regarding the hit-testing on pointermove I believe they can always add move handlers to the document and then they will always get that pointermove and they can do their own hit-testing.
For the other scenario how would one library get that pointerId in the first place? I guess this is discussed in more detail during Hackathon but can you give a more concrete example that one might use this API?

@RByers

This comment has been minimized.

Show comment
Hide comment
@RByers

RByers Jul 29, 2016

Contributor

The use case is certainly week - we're not sure this is high value, but we thought it might help reduce the risk of having implicit capture for some pointers and not others, and was simple and straight forward enough that there seemed little harm.

But let me try to explain the case I came up with a little better. Yes such a library would have pointermove handlers on the document where they'd want to do their own hit-testing. But in the uncaptured case, that extra hit-test would be redundant and unfortunate. It would be nice if the library could do the hit-test only in the case where it knew the target didn't represent a hit-test.

Contributor

RByers commented Jul 29, 2016

The use case is certainly week - we're not sure this is high value, but we thought it might help reduce the risk of having implicit capture for some pointers and not others, and was simple and straight forward enough that there seemed little harm.

But let me try to explain the case I came up with a little better. Yes such a library would have pointermove handlers on the document where they'd want to do their own hit-testing. But in the uncaptured case, that extra hit-test would be redundant and unfortunate. It would be nice if the library could do the hit-test only in the case where it knew the target didn't represent a hit-test.

@scottgonzalez

This comment has been minimized.

Show comment
Hide comment
@scottgonzalez

scottgonzalez Jul 29, 2016

Member

That sounds correct to me as well.

Member

scottgonzalez commented Jul 29, 2016

That sounds correct to me as well.

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