community-edition icon indicating copy to clipboard operation
community-edition copied to clipboard

Expected length "-Infinity"

Open evtaranov opened this issue 8 years ago • 12 comments

Hello!

I looked into some of your source code, and realized that in case of using 'Straight' connector it is possible to get unhandled errors. Here (https://github.com/jsplumb/jsPlumb/blob/master/src/connectors-straight.js#L28) in case when connector length is zero (for example while dragging new connection) due to this (https://github.com/jsplumb/jsPlumb/blob/master/src/defaults.js#L574) check, and because couple of lines above we have resetted (https://github.com/jsplumb/jsPlumb/blob/master/src/connection.js#L440) bounds into infinitives and then called calculate (https://github.com/jsplumb/jsPlumb/blob/master/src/defaults.js#L688) function, connector bounds will not be re-calculated during compute function call at all.

This cause to errors like this:

jsplumb.js:13036 Error: <svg> attribute width: Expected length, "-Infinity".
jsplumb.js:13036 Error: <svg> attribute height: Expected length, "-Infinity".

This issue occurs when you starting to drag a new connection and move cursor very close to source endpoint i.e. when connection length is zero.

evtaranov avatar Feb 03 '17 07:02 evtaranov

I think I have a related warning, when connecting two nodes programmatically I get

"Unexpected value -Infinity parsing width attribute. "

Although only in some cases, I haven't figured out how to reproduce that.

BMaxV avatar Apr 26 '17 09:04 BMaxV

I have the same issue, and also did Edward Wong a year ago: https://groups.google.com/forum/#!topic/jsplumb/PuDfP5QbQfc

I should provide a minimal code reproducing this bug, but I really can't right now, sorry

Lucas-C avatar Sep 22 '17 20:09 Lucas-C

@Eugenitals @Lucas-C did you find any workarounds for this issue?

andrewfan avatar Jan 20 '18 12:01 andrewfan

Speaking about reproduction you can use this demo https://jsplumbtoolkit.com/demos/wrapped/draggableConnectors/index.html for example, click on the green dot and try to slightly drag it to the top.

andrewfan avatar Jan 20 '18 12:01 andrewfan

@andrewfan No i didn't. But actually it didn't break my code, just spam in console.

evtaranov avatar Jan 26 '18 05:01 evtaranov

this issue hasn't been resolved yet, has it?

nxhoang avatar May 24 '18 06:05 nxhoang

  1. The reason of the problem is because you addNode and addEdge before rendering, and those endpoint are overlapping.
  2. So you need to put those addNode, addEdge in toolkit.batch(...).
  3. batch() temporary stops rendering, do things in batch(), and refresh afterwards. Just search for batch() in jsplumb you will understand.

wuduhren avatar Aug 31 '18 07:08 wuduhren

hmm but those method calls are in the Toolkit edition, @wuhduhren .

sporritt avatar Aug 31 '18 11:08 sporritt

Yeah, I am using the Toolkit. But I saw batch in community edition's document too. https://jsplumbtoolkit.com/community/doc/home.html (search: batch

wuduhren avatar Sep 01 '18 02:09 wuduhren

I'm using Community, and the batch() option doesn't not stop this error from happening in the console.

thenewbeat avatar Sep 26 '18 16:09 thenewbeat

I fixed this in pull request jsplumb/jsplumb#788 for our connector configuration (StateMachine). I think it also works for other connector configurations.

JordyvanDortmont avatar Oct 04 '18 14:10 JordyvanDortmont

Still facing this error.

baibhabmondal avatar Aug 05 '21 05:08 baibhabmondal