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

ReactSVGPanZoom onclick get svg polygon or rect name #182

Open
TWifast opened this issue Oct 2, 2020 · 1 comment
Open

ReactSVGPanZoom onclick get svg polygon or rect name #182

TWifast opened this issue Oct 2, 2020 · 1 comment

Comments

@TWifast
Copy link

TWifast commented Oct 2, 2020

HI. How can I use ReactSVGPanZoom onclick get the ID and NAME of SVG polygon rect.

@vash15
Copy link

vash15 commented May 4, 2022

Hi, try this, it worked for me

<ReactSVGPanZoom
    ref={Viewer}
    onClick={(e) => {
        const point = e.point;
        const target = e.originalEvent.target;
        const id = target.id;
        const tagName = target.tagName;
        
        console.log("Click:", tagName, id );
        console.log("Point", point);
        
        Viewer.current.setPointOnViewerCenter(point.x, point.y, 10);



    }}
>
    <svg width={width || 0} height={height || 0} >
    {content}
    </svg>
</ReactSVGPanZoom>

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

No branches or pull requests

2 participants