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

Clicking on img pixel to return the x and y of the clicked img pixel #21

Closed
danieldimit opened this issue Sep 18, 2019 · 1 comment
Closed

Comments

@danieldimit
Copy link

Nice work! Really useful widget.
It would be useful if the feature could somehow return the position of the clicked pixel as a relative value (values between 0 and 1. Coordinate (0,0) being top left, (1,1) being bottom right corner).

@danieldimit
Copy link
Author

Ok I found the following workaround:

import $ from 'jquery';

class ImageAndControllerContainer extends Component {
    
    componentDidMount() {
        $('#image-plane').on('dblclick',(e)=> {
                 if (e.target.id === 'canvas') {
                     // DO STUFF HERE
                 }
            }
        });
    }

    render() {
        return (
                <div id="image-plane">
                    <TransformWrapper dbClickEnabled={false} defaultScale={1} defaultPositionX={0} defaultPositionY={0} limitToBounds={false}>
                           .....
                           <img id='canvas' />
                    </TransformWrapper>
                </div>
        );
    }
}

export default ImageAndControllerContainer;

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

1 participant