Skip to content

onCreateNode mouse position#98

Merged
ajbogh merged 6 commits into
uber:masterfrom
iamsoorena:oncCreateNode-mouse-position
Jan 7, 2019
Merged

onCreateNode mouse position#98
ajbogh merged 6 commits into
uber:masterfrom
iamsoorena:oncCreateNode-mouse-position

Conversation

@iamsoorena

Copy link
Copy Markdown
Contributor

before:

this.props.onCreateNode(xycoords[0], xycoords[1]);

after:

this.props.onCreateNode(xycoords[0], xycoords[1], {pageX: d3.event.pageX, pageY: d3.event.pageY});

User can interact with the actual mouse position with this option.

@iamsoorena iamsoorena changed the title OnCreateNode mouse position onCreateNode mouse position Dec 12, 2018
@ajbogh

ajbogh commented Dec 13, 2018

Copy link
Copy Markdown
Contributor

I would recommend documenting a change and bumping the major version on this. Please document the change in the README and add the previous implementation to the deprecated section.

We will release a major version update for this.

Generally speaking, a major version would not normally be necessary, however we have a large customer that seems to have added a final parameter to their onCreateNode function, overloading it to perform some other tasks. If we don't do a major version change then they'll get the update and the extra tasks will always be performed (object shallow-equals true).

@ajbogh

ajbogh commented Dec 14, 2018

Copy link
Copy Markdown
Contributor

I think a better approach would be to pass back the mouse event. I believe the old v4 code passed back both the mouse event as well as the d3 object.

Another alternative within onCreateNode is to use d3.mouse() directly and make sure to pass it the SVG container (d3.mouse(svg)). This method removes the need to add extra parameters to onCreateNode but requires client websites to install and import/require d3.

@iamsoorena

Copy link
Copy Markdown
Contributor Author

@ajbogh I'll add the readme for sure.
I think passing back d3 mouse event is even giving more power to the parent library user.
But I don't think requiring d3 for parent website is a good idea, They can easily break everything apart If they don't use d3 with caution.
I think It's better for parent website to be separated from d3 completely.

@iamsoorena

Copy link
Copy Markdown
Contributor Author

@ajbogh I just documented the changes in Readme and replaced event with {pageX, pageY} declaration.

@iamsoorena

Copy link
Copy Markdown
Contributor Author

@ajbogh Please, Please consider merging this. 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

@ajbogh

ajbogh commented Jan 7, 2019

Copy link
Copy Markdown
Contributor

Sorry for the delay. I needed to talk with one of our primary users to determine a proper version number for this. They happened to overload the createNode callback function with other parameters, so we will need to create a major version bump instead of a minor change so that they don't accidentally install the change and break themselves.

@ajbogh
ajbogh merged commit 46f2da6 into uber:master Jan 7, 2019
@ajbogh

ajbogh commented Jan 7, 2019

Copy link
Copy Markdown
Contributor

This is published as 6.0.0. Thanks!

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