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

add Passive event listener arguments to .on() #113

Closed
mark3448 opened this issue Jan 30, 2017 · 3 comments
Closed

add Passive event listener arguments to .on() #113

mark3448 opened this issue Jan 30, 2017 · 3 comments

Comments

@mark3448
Copy link

talking about this:
https://dom.spec.whatwg.org/#dictdef-eventlisteneroptions

for more information:
https://medium.com/@devlucky/about-passive-event-listeners-224ff620e68c#.1awhbyd87

could be good to add:
on(type:string, listener?:$$.ValueFunction, capture?:boolean, options?):this;

and then you could do .on('click',()=>,{passive: true});

@mbostock
Copy link
Member

This already works because selection.on just passes through the optional third capture argument without any consideration as to what it means or what type it has. For example:

d3.select("body").on("click", () => console.log("click"), {once: true})

So, the simplest thing to do would be to rename capture in the documentation (and internal parts of the code) to options, and then close this issue.

@xiaoshidetaikuai
Copy link

excuse me,How can I use passive for zoom? I see code is

 selection
        .property("__zoom", defaultTransform)
        .on("wheel.zoom", wheeled)
        .on("mousedown.zoom", mousedowned)
        .on("dblclick.zoom", dblclicked)
      .filter(touchable)
        .on("touchstart.zoom", touchstarted)
        .on("touchmove.zoom", touchmoved)
        .on("touchend.zoom touchcancel.zoom", touchended)
        .style("touch-action", "none")
        .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");

@mbostock
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants