joint icon indicating copy to clipboard operation
joint copied to clipboard

Flip Element

Open mkzaker opened this issue 10 years ago • 12 comments

Hi everyone, Is there a way to flip the elements?

mkzaker avatar Nov 04 '15 10:11 mkzaker

Yes, you can use element.rotate(180).

chill117 avatar Nov 04 '15 10:11 chill117

there is a different between flip that i want to use and rotate(180) i want a case like mirror that change element direction but in rotate,element turn around a point i want to flip horizontal and vertical

mkzaker avatar Nov 04 '15 10:11 mkzaker

This is currently not supported. What you mean is a negative scale (http://stackoverflow.com/questions/23899718/scale-and-mirror-svg-object) which we don't support yet. However, it is definitely an interesting feature worth researching.

DavidDurman avatar Nov 04 '15 11:11 DavidDurman

+1 please. this would be a great feature to have. Can we get it on the roadmap?

kmansel avatar Nov 05 '15 23:11 kmansel

+1 please

mkzaker avatar Nov 06 '15 05:11 mkzaker

Any news on this little guy?

kmansel avatar Jan 13 '16 23:01 kmansel

Unfortunately none of us here have had time to tackle this issue just yet.

chill117 avatar Jan 14 '16 10:01 chill117

A workaround for time being that might help someone.

kumilingus avatar Jan 23 '16 11:01 kumilingus

Here's yet another workaround (using a custom attribute).

kumilingus avatar Jan 08 '18 17:01 kumilingus

This issue is stale because it has been open 60 days with no activity. Please remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Jun 22 '23 00:06 github-actions[bot]

@kumilingus Has the team had a chance to implement this functionality?

gintarasgraciovas avatar Feb 08 '24 15:02 gintarasgraciovas

No, our focus was elsewhere.

Using the calc expressions a solution can be simple as this:

joint.dia.Element.define('MyElement', {
    attrs: {
        wrapper: {
            // flip-x
            transform: 'scale(-1, 1) translate(-calc(w), 0)'
        },
    }
}, {
    markup: util.svg`
        <g @selector="wrapper">
            <path @selector="body" />
            <text @selector="label" />
        </g>
    `
});

/ flip-y
el.attr('wrapper/transform', 'scale(1, -1) translate(0, -calc(h))');

// flip-x and flip-y
// transform = 'scale(-1, -1) translate(-calc(w), -calc(h))'

Is this way of flipping not working for you? If not, please let us know why.

kumilingus avatar Feb 09 '24 02:02 kumilingus