retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
9.86k stars 647 forks source link

Issue with Connection Bounding Box #267

Closed prog-r-amer closed 5 years ago

prog-r-amer commented 5 years ago

Hi,

I have an issue with giving the connections hover elements, because of the bounding box of the svg.

.main-path:hover { stroke: green !important; }

This doesn't work everywhere. If I give svg an absolute size like 10000px it works in a bigger area, but not when you translate the area. Can you give the svg the width and height properties according do the path inside it, so hover / onclick works everywhere?

Ni55aN commented 5 years ago

As I remember, SVG with large sizes will be overlayed on frames (from comment-plugin)

screenshot from 2019-02-26 19-47-31

It seems that this is a bug with SVG, since the hover zone does not correspond to the actual size of the SVG

prog-r-amer commented 5 years ago

It goes a bit outside of the size of the svg, but it always works when the svg is bigger than the path. I would still appreciate an option to make the svg size bigger, since I don't use the comment plugin myself.

prog-r-amer commented 5 years ago

You were right, even if I set the svg size to the same size as the node editor hover doesn't always work. Do you have any suggestions how I get the hover to work 100% of the time?

Ni55aN commented 5 years ago

I don't. Seems like a bug in SVG, since I have not found a logical explanation for this behavior. Moreover, if the SVG size is too small, the coordinates of a connections may offset. This happens on all WebKit browsers.

Ni55aN commented 5 years ago

I will be grateful if someone finds examples with the reproduction of such behavior on a regular SVG (outside the framework)

prog-r-amer commented 5 years ago

I don't believe it's a bug in svg, I only get it within rete. Could it be something with drag or onclick events not propagating correctly and because of that the element doesn't get the mouseover event?

Ni55aN commented 5 years ago

@prog-r-amer I have reproduced the bug: https://codepen.io/Ni55aN/pen/jJGVYe

Anyway, starting from rete-connetion-plugin@0.5.0-rc.1 it was fixed

prog-r-amer commented 5 years ago

wow, thanks mate. I only have 1 issue now after upgrading: without

.connection {width: auto; height: auto}

it looks like this: https://imgur.com/a/mkHsqgY

I don't get the hover bug anymore though and this css fixes it for me. Just wanted to report it.

prog-r-amer commented 5 years ago

Ok, very rarely I still manage to not get hover working right, but it's far better than before.

Ni55aN commented 5 years ago

Maybe you have an inherited styles?

prog-r-amer commented 5 years ago

By the way, with

pointer-events: all; your codepen works bugfree for both paths.

prog-r-amer commented 5 years ago

No, it's with the 1px width and height, that it doesn't work.

Ni55aN commented 5 years ago

Is the example have any issues?

prog-r-amer commented 5 years ago

On my mobile phone it looks the same as the example I sent you. On my desktop pc it works.

Ni55aN commented 5 years ago

What is your mobile OS and browser?

prog-r-amer commented 5 years ago

Android with Chrome

Ni55aN commented 5 years ago

It's strange. I don't have any issues on Android 7.0 with Chrome 72

prog-r-amer commented 5 years ago

For Reference: https://imgur.com/a/3zuY7Bx

Chrome Version is 72 too.

prog-r-amer commented 5 years ago

Why do you set the width and height for the svg? It sets the ratio of the svg, and I think this is what causes the bug in some browsers.

I think you should set the width and height of the absolute positioned container, and give the svg no width and height attributes. This might also solve the still sometimes occuring hover bug, if you set the container to the actual dimensions of the svg, although I am not sure about that.

Ni55aN commented 5 years ago

Why do you set the width and height for the svg?

in some cases SVG may overlap other elements

I think you should set the width and height of the absolute positioned container, and give the svg no width and height attributes.

This doesn't work. SVG will still overlap Screenshot from 2019-03-15 11-46-14

prog-r-amer commented 5 years ago

Why is it not allowed to overlap? And in the Image you posted the width and height are still 1px.

Ni55aN commented 5 years ago

Why is it not allowed to overlap?

it will blocks a mouse events

And in the Image you posted the width and height are still 1px.

with of div, not SVG

prog-r-amer commented 5 years ago

You can control the mouse events with pointer-events property of elements.

Ni55aN commented 5 years ago

pointer-events none doesn't working with root SVG

prog-r-amer commented 5 years ago

Today I learned...

bfritscher commented 5 years ago

I also have the bug on my desktop. The svg element bounding box is fine but the coordinates are wrong due to scaling factor of the HDPI display 150%.

connector bug

On the other hand the 3D car configurator example works

Ni55aN commented 5 years ago

I can not give an explanation for this, since it looks like a bug at the level of the webkit engine

Ni55aN commented 5 years ago

The temporary solution is adding width: auto; height: auto to SVG, but it may lead to overlaying of other elements

Ni55aN commented 5 years ago

The same issue on Win10 with an interface scale of 125% (the browser has 100%)

Opera Снимок_2019-03-31_102309_codepen io

Ni55aN commented 5 years ago

I deleted width and height constraints on SVG (which leads to a strange problem with a scaling) I hope that position: absolute and pointer-events: none will solve the issue of clicking on comment/frame in all major browsers

rete-connection-plugin@0.6.4 published https://github.com/retejs/connection-plugin/commit/39c55569fcefeedf134aa7e2017908c0a14d2d62

Ni55aN commented 5 years ago

The most interesting thing is that pointer-events does not work without position: absolute

Ni55aN commented 5 years ago

https://github.com/retejs/connection-plugin/issues/12