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

Event code on the readme does not work #20

Closed
jeremynac opened this issue Dec 18, 2020 · 1 comment
Closed

Event code on the readme does not work #20

jeremynac opened this issue Dec 18, 2020 · 1 comment

Comments

@jeremynac
Copy link

The code on the readme that demonstrates events calls the events: selectNode, hoverNode. I tried it and it does not work, it only works if I call them select-node and hover-node, like in the 'examples' folder.
Maybe I'm wrong but my guess is someone updated the library but forgot to update the readme.
I would be happy to do so.
It's a really nice project by the way, keep the good work!

@uier
Copy link
Contributor

uier commented Dec 25, 2020

@jeremynac yeah, I think your guess is right.

The Network component emits the event whose name is the return value of translateEvent(eventName).

this.events.forEach(eventName =>
this.network.on(eventName, props =>
this.$emit(translateEvent(eventName), props)
)
);

and what translateEvent do is to turn the Camel Case event name into kebab Case.

const translateEvent = event => {
return event.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
};

So it only works when we call them in kebab Case.

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

2 participants