mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 00:12:21 +00:00
Fix hit testing when using react-native transform arrays.
This commit is contained in:
@@ -191,12 +191,13 @@ class GroupView extends RenderableView {
|
||||
|
||||
@Override
|
||||
int hitTest(final float[] src) {
|
||||
if (!mInvertible) {
|
||||
if (!mInvertible || !mTransformInvertible) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
float[] dst = new float[2];
|
||||
mInvMatrix.mapPoints(dst, src);
|
||||
mInvTransform.mapPoints(dst, src);
|
||||
|
||||
int x = Math.round(dst[0]);
|
||||
int y = Math.round(dst[1]);
|
||||
|
||||
@@ -428,12 +428,13 @@ abstract public class RenderableView extends VirtualView {
|
||||
|
||||
@Override
|
||||
int hitTest(final float[] src) {
|
||||
if (mPath == null || !mInvertible) {
|
||||
if (mPath == null || !mInvertible || !mTransformInvertible) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
float[] dst = new float[2];
|
||||
mInvMatrix.mapPoints(dst, src);
|
||||
mInvTransform.mapPoints(dst, src);
|
||||
int x = Math.round(dst[0]);
|
||||
int y = Math.round(dst[1]);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package com.horcrux.svg;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
@@ -990,8 +991,10 @@ class RenderableViewManager extends ViewGroupManager<VirtualView> {
|
||||
resetTransformProperty(node);
|
||||
} else {
|
||||
setTransformProperty(node, matrix);
|
||||
node.mTransform = node.getMatrix();
|
||||
}
|
||||
Matrix m = node.getMatrix();
|
||||
node.mTransform = m;
|
||||
node.mTransformInvertible = m.invert(node.mInvTransform);
|
||||
}
|
||||
|
||||
@ReactProp(name = "propList")
|
||||
|
||||
@@ -971,12 +971,13 @@ class TSpanView extends TextView {
|
||||
if (mContent == null) {
|
||||
return super.hitTest(src);
|
||||
}
|
||||
if (mPath == null || !mInvertible) {
|
||||
if (mPath == null || !mInvertible || !mTransformInvertible) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
float[] dst = new float[2];
|
||||
mInvMatrix.mapPoints(dst, src);
|
||||
mInvTransform.mapPoints(dst, src);
|
||||
int x = Math.round(dst[0]);
|
||||
int y = Math.round(dst[1]);
|
||||
|
||||
|
||||
@@ -81,12 +81,13 @@ class UseView extends RenderableView {
|
||||
|
||||
@Override
|
||||
int hitTest(float[] src) {
|
||||
if (!mInvertible) {
|
||||
if (!mInvertible || !mTransformInvertible) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
float[] dst = new float[2];
|
||||
mInvMatrix.mapPoints(dst, src);
|
||||
mInvTransform.mapPoints(dst, src);
|
||||
|
||||
VirtualView template = getSvgView().getDefinedTemplate(mHref);
|
||||
int hitChild = template.hitTest(dst);
|
||||
|
||||
@@ -62,7 +62,9 @@ abstract public class VirtualView extends ViewGroup {
|
||||
Matrix mMatrix = new Matrix();
|
||||
Matrix mTransform = new Matrix();
|
||||
Matrix mInvMatrix = new Matrix();
|
||||
Matrix mInvTransform = new Matrix();
|
||||
boolean mInvertible = true;
|
||||
boolean mTransformInvertible = true;
|
||||
private RectF mClientRect;
|
||||
|
||||
private int mClipRule;
|
||||
|
||||
Reference in New Issue
Block a user