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

[Feature] useMouseMove hook to observe x,y coords of window or an html element #43

Merged
merged 4 commits into from
Feb 18, 2019

Conversation

saniakjamil
Copy link
Contributor

Solved #38 .

Added useMouseMove hook to set of hooks.
Added documentation and example in dev/index.js.

@adeelibr
Copy link
Member

adeelibr commented Feb 14, 2019

This is super cool @saniakjamil

Let's add some super cool wings to this hook. My proposed version of this hook is something like this

const styles = {
 miniBox: {
  height: 450,
  width: 300,
  backgroundColor: 'yellow', 
 }, 
};

const App = () => {
 const [coords] = useMouseMove();
 const [yellowBoxCoords, yellowBoxRef ] = useMouseMove();
 
 return (
   <div>
       <p>your current mouse position with respect to window container {coords.x}, {coords.y}</p>
       <section ref={yellowBoxRef} style={styles.miniBox}>
         <p>mouse x,y with respect to yellow box {yellowBoxCoords.x}, {yellowBoxCoords.y}</p>
       </section>
   </div>
 );
}

So in short, an API that can do both. Does that make sense?

Inpirations/References:

@adeelibr adeelibr changed the title Feature/use mouse move [Feature] useMouseMove hook to observe x,y coords of window or an html element Feb 14, 2019
@adeelibr adeelibr merged commit 4cbbe1a into withvoid:master Feb 18, 2019
@adeelibr
Copy link
Member

💯

@adeelibr adeelibr mentioned this pull request Feb 18, 2019
3 tasks
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

Successfully merging this pull request may close these issues.

2 participants