joint icon indicating copy to clipboard operation
joint copied to clipboard

Link disappears when filter applied

Open DorothyGuan opened this issue 5 years ago • 4 comments

  • jointjs version: 3.1.1
  • Platform: macOS Mojave Google Chrome 83.0.4103.61
  • Description:

I want to add some filter effects when I hover a link. So I add 'link:mouseenter' and 'link:mouseleave' listeners on the graph to change corresponding attrs. (I don't know whether this usage is recommended or not).

Links work well if they are not straight. But if I move a node to make the link horizontal or vertical, it will disappear after hover action.

Here is a example: jointjs-demo.zip (I'm sorry I can't provide an online reproduce link, so I wrote a html example to explain this question. )

DorothyGuan avatar Jun 03 '20 08:06 DorothyGuan

Please see https://resources.jointjs.com/tutorial/links-patterns spec. Pure vertical and horizontal lines.

kumilingus avatar Jun 03 '20 08:06 kumilingus

I read this section and define a custom connector which extends the built-in 'rounded' connector for this situation, then I find a new problem. The line won't disappear finally, but it gets slimmer after hover action. And the shadow seems not as obvious as a winding line acts. When I adjust the 'width' or 'height', the shadow changes along with the 'slope' change. More sloping, more obvious the shadow is. Like these:

屏幕快照 2020-06-03 下午6 54 23 屏幕快照 2020-06-03 下午7 05 56 jointjs-demo.html.zip

It seems not that perfect in a display scene. So Maybe I need to consider another way to solve this problem. However, Thanks for your reply 😊

DorothyGuan avatar Jun 03 '20 11:06 DorothyGuan

Not find a better way, so I give up shadow filter and use stroke in replace.

DorothyGuan avatar Jun 05 '20 10:06 DorothyGuan

Hi, sorry for late reply. The problem is that we use objectBoundingBox for filterUnits here. That means the size of the shadow depends on size of the node it applies to.

From MDN:

objectBoundingBox In that case, x, y, width and height represent fractions or percentages of the bounding box on the referencing element.

I am marking this as a bug.

kumilingus avatar Jun 07 '20 19:06 kumilingus

hi,

I have exactly the same problem with horizontal links. I use filters to make a double line link, but this bug happens. Is there a solution or alternative to make my double line?

2022-11-15_11-43 2022-11-15_11-42

Thanks

cgiuliani avatar Nov 15 '22 10:11 cgiuliani

Please see https://resources.jointjs.com/tutorial/links-patterns spec. Pure vertical and horizontal lines.

This is a workaround.

And joint.shapes.standard.DoubleLink is an alternative.

kumilingus avatar Nov 15 '22 11:11 kumilingus

Update: this seems to work nicely:

link.attr('line/filter': {
    name: 'dropShadow',
    args: { dx: 2, dy: 2, blur: 3 },
    attrs: {
        filterUnits: 'userSpaceOnUse',
        // Reset to the default values
        x: '-10%',
        y: '-10%',
        width: '120%',
        height: '120%'
    }
});

kumilingus avatar Jun 17 '23 13:06 kumilingus

Fixed in v4.0.0.

kumilingus avatar Feb 02 '24 10:02 kumilingus