strathausen / dracula

JavaScript layout and representation of connected graphs.
https://www.graphdracula.net
MIT License
834 stars 132 forks source link

Can't draw inside my element. [function Renderer problems with Jquery] #41

Closed bagnus closed 7 years ago

bagnus commented 7 years ago

If Jquery (last version) is loaded, the function Renderer is not able to draw inside a wanted element. This is because jquery returns a wrapper to en element, not the dom element itself.

Test case: var renderer = new Renderer('#paper', graph, 400, 400); I have a div element with 'paper' id but the rendering doesn't happen inside it

The original code frangment is: if (typeof element === "string") {

                    var selector = typeof $ !== "undefined" ? $ : function(q) {
                        return document.querySelector(q)
                    };
                    element = selector(element);
                }

To solve my problem I modified into:

                if (typeof element === "string") {
                    element = (typeof $ !== "undefined")? $(element)[0]: document.querySelector(element);
                }

Regards Andrea

strathausen commented 7 years ago

Thanks for reporting this! Your change is now included. Can you verify that it's working for you?

bagnus commented 7 years ago

Ok. Tested with dev.js and min.js version. Ciao Andrea