GithubHelp home page GithubHelp logo

Comments (5)

happylilem avatar happylilem commented on May 27, 2024

I just tried to replace the altKeyZoom attribute with modKeyZoom('Alt'), the latter one works! So I suspect the problem might arise from line 212 in diagram.js:
_diagram.modKeyZoom = _diagram.altKeyZoom = property(false);

from dc.graph.js.

gordonwoodhull avatar gordonwoodhull commented on May 27, 2024

Hey, sorry I haven’t had a chance to look at this.

I think it is probably a documentation bug. It is definitely delicate and I am sure there is a better system, but there is usually a way to get it working, so I’ve never cleaned it up.

In situations like this it’s probably best to look for an example that does work and then see what it did.

Let’s see if we can document this better, and deprecate one of the APIs if the name is misleading.

from dc.graph.js.

happylilem avatar happylilem commented on May 27, 2024

Thanks for the reply! And yes, I think the documentation could be further improved because the 'altKeyZoom' attribute could be found by entering into the search bar but not 'modKeyZoom'. However, I don't quite understand why make them two different attributes while they should serve the same function (zoom with Alt key pressed). ('altKeyZoom' is used in the brushing and filtering demo, and 'modKeyZoom' is used in the drag-drop composition demo.)
On the other hand, I still think there's bug within the 'altKeyZoom' attribute because after my attempts I found that when it's set to false, the graph can be zoomed and moved; when it's true, the graph cannot be zoomed or moved (even after I pressed Alt).

from dc.graph.js.

gordonwoodhull avatar gordonwoodhull commented on May 27, 2024

IIRC what happened here is that we tried to add new functionality in a backward-compatible way, but we slipped up.

Originally it was a boolean altKeyZoom that allowed you to turn the feature on or off. Then we tried to generalize it to modKeyZoom taking a string or an array of strings, all of which must match the current modifier keys pressed, in order for the "mode" to be activated.

We probably tried to upgrade boolean into "Alt" at first, but broke it as we continued to change things.

So altKeyZoom should really be deprecated, or if it totally doesn't work, it should be outright removed.

The key-matching logic is here:

_mode.modKeysMatch = function(keys) {
if(!keys || keys === [])
return _pressed.empty();
if(!Array.isArray(keys))
keys = [keys];
var p = pressed();
if(p.length !== keys.length)
return false;
return keys.slice().sort().every(function(k, i) { return k === p[i]; });
};

Please let me know if using the string "Alt" works for you.

from dc.graph.js.

happylilem avatar happylilem commented on May 27, 2024

I just tried AltKeyZoom with 'Alt', and it worked! So it wasn't successfully set to Boolean and still carries the same function as modKeyZoom.

from dc.graph.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.