ethanselzer / react-cursor-position

A React component that decorates its children with mouse and touch coordinates relative to itself.
https://ethanselzer.github.io/react-cursor-position
MIT License
143 stars 35 forks source link

Expose width and height as props #6

Closed AlexMeah closed 7 years ago

AlexMeah commented 7 years ago

Not sure about the height being undefined happy to change it if it's a problem.

ethanselzer commented 7 years ago

@AlexMeah,

I apologize for not responding sooner. I don't know how I missed your PR, but I finally saw it today. I think your idea of exposing width and height is great! I would like to suggest we add a new property named elementDimensions to the output props. I like this approach because it may help to disambiguate the values and because it keeps the position property focused on x and y coordinates. The output props data structure would look like this:

{
    elementDimensions: {
        width: Number,
        height: Number
    }
    isActive: Boolean,
    isPositionOutside: Boolean,
    position: {
        x: Number,
        y: Number
    }
}

What are your thoughts?

I opened an Issue to track this feature and listed the tasks I think need to be performed. If you have time to do any of them, that is great. Otherwise, I will take some or all of them.

Thank you very much for opening this PR. You raised my awareness to a useful feature.

ethanselzer commented 7 years ago

@AlexMeah - I want to thank you for opening this PR. You contributed the concept of exposing width and height and I think that helped to make the project better. I wanted to take the implementation in a slightly different direction, so I apologize for closing this in favor of https://github.com/ethanselzer/react-cursor-position/pull/8. The NPM package has been released @2.1.0. Let me know if you have any questions or concerns. Thanks again!

AlexMeah commented 7 years ago

@ethanselzer Sorry I didn't get chance to implement it myself, https://github.com/ethanselzer/react-cursor-position/pull/8 looks great I'll switch away from my branch and start using it straight away :)

ethanselzer commented 7 years ago

@AlexMeah - Thanks for your kind words and thanks for starring the project. I'm so glad you find react-cursor-position useful!