-
Notifications
You must be signed in to change notification settings - Fork 22.9k
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
access what is set by the selectin.on() #216
Comments
There's on API for doing this currently, but you can access where we store the handler: Another thing you can do that's easy is to not use an anonymous function, and just call your function. For example: d3.select("#sensor").on("mouseover", mouseover);
d3.select("#actor").transition().each("end", mouseover);
function mouseover() {
// do some stuff here
} Lastly, issue #100 covers a request to trigger events on other objects, which would be another way of calling their event handlers. In this case, you could trigger a "mouseover" event on the desired elements, and all the associated event handlers would be run. |
Thanks, that surely solves my problem. I used a named function, but your code reads much better, I didn't realized that you can also modify the transition (created in mouseover function) by doing something like: d3.select("#actor").transition().each("end", mouseover); Very cool. I wonder if it is a good design to have the .on('mouseover') call to return the previously set mouseover handler? this works like the way of .attr() calls, sounds quite intuitive. Using this.__onmouseover is like working beneath the hood, which requires much knowledge of the implementation. |
Yeah, it'd be nice if .on("mouseover") returned the mouseover handler. |
Fixed in 2.0.0. @a4500fcfb112a011a59c123b000508cb326b453a |
I wonder if it is possible to access the event handler set by the selection.on() method. I tried quite a few but all failed. for example, I would like to blink a path by repeatedly call the same transition function:
d3.select('#sensor')
.on('mouseover', function(){
d3.select('#actor')
.transition()
.each('start', function(){d3.select(this).attr('stroke-width',1); })
.attr('stroke-width', 4).delay(1000)
.each('end', function(){ this.onmoueover(); })
The intention of the above code is to recursively call the function set by the on() method. Is there anyway to get it done? I also tried to use selection.on('mouseover') to access the set function, without luck.
Regards,
Lane
The text was updated successfully, but these errors were encountered: