Skip to content

Commit

Permalink
[android] fix text hit test
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Jul 2, 2018
1 parent a454fe3 commit d982130
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions android/src/main/java/com/horcrux/svg/TSpanShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -947,4 +947,39 @@ private void setupTextPath() {
parent = parent.getParent();
}
}

@Override
public int hitTest(final float[] src) {
if (mContent == null) {
return super.hitTest(src);
}
if (mPath == null || !mInvertible) {
return -1;
}

float[] dst = new float[2];
mInvMatrix.mapPoints(dst, src);
int x = Math.round(dst[0]);
int y = Math.round(dst[1]);

if (mRegion == null) {
mRegion = getRegion(mPath);
}
if (!mRegion.contains(x, y)) {
return -1;
}

Path clipPath = getClipPath();
if (clipPath != null) {
if (mClipRegionPath != clipPath) {
mClipRegionPath = clipPath;
mClipRegion = getRegion(clipPath);
}
if (!mClipRegion.contains(x, y)) {
return -1;
}
}

return getReactTag();
}
}

0 comments on commit d982130

Please sign in to comment.