[event] add touchEvt support to localPnt, find owner svg. fixes #15 #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #15
Adds single arity support to
localPoint(event)
which will find the ownerSVG and loop for the owner on nested SVG. This use case was found by @conglei when his chart has nested svg icons that had event handlers. Thanks to @conglei for pointing this out.You can still pass in a reference to a specific svg if you want your local point relative to a specific svg element by using dual arity
localPoint(svgNode, event)
orlocalPoint(event.target.ownerSVGElement, event)
.Lastly, this adds touch event support to
localPoint
so you don't have to usetouchPoint
andlocalPoint
.touchPoint
will still exist to prevent breaking changes for folks. I also addedtouchPoint
to the exports on index so you can now doimport { touchPoint } from '@vx/event'
if you want to.Updated the /areas demo to support touch events and mouse events with the new single arity usage.
future will probably need a
localTouchPoints
that returns an array of localevent.changeTouches
points sincelocalPoint
returns the the firstevent.eventTouches
and ignores the rest.