I have an element that contains a child svg (rect+text). When I try to resize it I am getting an error:
The latest jsPlumb.js is bundled into a vendorbundle.js file. Other things work fine (drag+drop, connections, etc).
My block is defined like this:
<div id="baseBlock" class="tool resizableHandle">
<text version="1.1" xmlns="
http://www.w3.org/1999/xhtml" width="100" height="100" text-anchor="middle" x="50" y="50" class="blockPart" dominant-baseline="central">Base Block</text>
</svg>
</div>
In my resizable start function I am trying to assign all children nodes that are blockPart to also have a resizableChild class. Doing this because I'm cloning an item on drag+drop and only want the resizable class during the resize event, otherwise ALL elements get resized.
Like this:
start: function (event, ui) {
$(ui.helper).find('.blockPart').each(function (i, item) {
console.log("blockPart: " + item);
var $item = $(item);
if ($item.hasClass('blockPart') && item.hasAttribute('width')) {
console.log("hasClass:true");
$item.addClass('resizableChild');
}
});
},
stop: function (event, ui) {
$(ui.helper).find('.blockPart').each(function (i, item) {
var $item = $(item);
if ($item.hasClass('resizableChild')) {
$item.removeClass('resizableChild');
}
});
}
Here is the actual error:
Uncaught TypeError: Cannot read property 'width' of undefined
at String.<anonymous> (vendorbundle.js:19807)
at Function.each (vendorbundle.js:365)
at SVGSVGElement.<anonymous> (vendorbundle.js:19806)
at Function.each (vendorbundle.js:365)
at jQuery.fn.init.each (vendorbundle.js:137)
at jQuery.fn.init.resize (vendorbundle.js:19800)
at Object.call (vendorbundle.js:12149)
at $.<computed>.<computed>._propagate (vendorbundle.js:19525)
at $.<computed>.<computed>._propagate (vendorbundle.js:12260)
at $.<computed>.<computed>._mouseDrag (vendorbundle.js:19190)
The error happens when I try to resize, if I clear out the alsoResize property the error stops. Something in the context of "alsoResize" seems to be null, but I don't see what. The console output has what is expected - aside from the unexpected error:
toolPart: [object SVGSVGElement]
hasClass:true
toolPart: [object SVGRectElement]
hasClass:true
toolPart: [object SVGTextElement]
hasClass:true
Any ideas?
Thanks!
Will