Closed iyobo closed 5 years ago
We can introduce a method for getting paper dimensions. If the value is percentage we ask the DOM for the size. if it's a number we return this number.
In the meantime, you might also experiment with getters/setters as shown below.
Object.defineProperty(paper.options, 'width', {
get: function() { return $(this.el).width(); }
});
paper.$el.css('width', '100%');
paper.scaleContentToFit();
Fixed by f40c4f2fe0e344afed759e5c964deb0f466583d7
How to handle the issue in 4.x version?
Please provide a steps to reproduce.
I have a responsive jointjs graph and I have the width of the paper set to 100% i.e
This works well and width scales responsively.. However when I do
paper.scaleContentToFit();
, I get an empty graph.If I attempt to click into the empty graph dom, I get the error:
obviously the stacktrace lines are being obfuscated by my bundler, but it is clear that paper does not know hot to handle scaling if the dimension [i.e width] is a percentage.
I suggest that, when doing this scaling, width and height should be grabbed from the DOM's actual width and height, as opposed to what may have been set when initializing the paper object.
This ensures responsive styling of the graph AND allows auto scaling.