Closed junyuanz123 closed 7 years ago
Hi,
Thanks for opening your issue. The feature you describe is not currently supported, but I would like to support it. To achieve the greatest utility from the implementation I would like to make it as general as possible. I propose child components and subscribers to onCursorPositionChanged
receive a new Boolean property that would be set to true when the cursor is outside the bounds of the target element. Do you think that would address the use case you are inquiring about?
I'm very happy that react-cursor-position is working well for you!
That would be perfect! Thank you so much!
I will also study the code. I might be able to implement this.
Okay great! I will get started on adding this feature. I think it will be ready in one to two days.
The feature is ready! Child components and subscribers to onCursorPositionChanged
will receive a new property named isOutside
. Please see updated code release and npm package @ V1.2.
Thanks again for opening and issue. Please let me know if the new release addresses your use case.
Thank you so much!
Sorry to bother you again.
This code is working perfectly now. But I am just wondering Is there any way I can override the onMouseLeave function to make x, y equal to null?
Thanks!
Please don't apologize. My goal is to make react-cursor-position useful to you. We are on the same team!
It looks like you closed the issue. Does that mean you found a solution?
I'm envisioning an enhancement to the API that would allow consumers to map the name and values of child component props (see below). Would that be helpful to you?
mapProps: (props) => {
if (props.cursorPosition.isOutside) {
return {
cursorPosition: {
x: null,
y: null,
};
}
return props;
}
Oh, thanks for the reply. I rethink about this question, and I think adding another function doesn't make any sense, so I close this issue.
Hi,
This tool works perfectly for our project. However, I have a question, is that possible to reset the cursor information when it moves out the object?
Thanks!