Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickering when dragging a group with an SVG in it #127

Closed
lucafaggianelli opened this issue Oct 28, 2020 · 8 comments
Closed

Flickering when dragging a group with an SVG in it #127

lucafaggianelli opened this issue Oct 28, 2020 · 8 comments

Comments

@lucafaggianelli
Copy link

I have a group element <g> containing several elements, there's always an <svg> and optionally other stuff. The drag and drop works but it flickers a lot and the drop position is not correct.

https://codepen.io/lucafaggianelli/pen/eYzVmxx?editors=0010

const draw = SVG().size(500, 500).addTo('body')
const table = draw.group()
  .svg(TABLE)
  .draggable()

Moreover I need to resize the loaded image inside the group and if I do that, the situation is worse as the element jump out of the window (literally :))

const table = draw.group()
  .svg(TABLE)
  .draggable()
  .last().size(100)
@Fuzzyma
Copy link
Member

Fuzzyma commented Oct 28, 2020

And I thought this plug-in was finally stable...
I'll look into it but it might take some time.

@lucafaggianelli
Copy link
Author

Yes it seems a pretty delicate matter, when I drag the group only the inner svg is moved via x and y attrs, so I tried to make a custom drag logic applying a translation to the g element and situation is better but still buggy

@Fuzzyma
Copy link
Member

Fuzzyma commented Oct 29, 2020

This is actually the correct behavior because groups just inherit the position if it's content. So if you love the content the group moves. But obviously something is not working out here

@alexanderGerbik
Copy link

A possible work-around - move each element of the group manually:

let lastPoint;
group.draggable().on('dragstart', (e) => {
  lastPoint = e.detail.p;
}).on('dragmove', (e) => {
  e.preventDefault();
  const currentPoint = e.detail.p;
  const dx = currentPoint.x - lastPoint.x;
  const dy = currentPoint.y - lastPoint.y;
  // move each element of the group
  lastPoint = currentPoint;
})

@antonioaltamura
Copy link

is there any news about this?

@Fuzzyma
Copy link
Member

Fuzzyma commented Jun 27, 2024

Sorry for never getting back to this.
I looked into this, and this seemed to an inconsistent behavior with nested svgs in groups.
If you call draggable on the svg instead of the group it works.

Still a bug tho.

Working example:
https://codepen.io/fuzzyma/pen/OJYGvpM?editors=0010

@Fuzzyma
Copy link
Member

Fuzzyma commented Jun 27, 2024

Found a FF bug while working on this: https://bugzilla.mozilla.org/show_bug.cgi?id=1905012

But that doesnt seem to be the issue because the same behavior can be observed in chrome

@Fuzzyma
Copy link
Member

Fuzzyma commented Jun 27, 2024

Found a second FF bug while working on this which makes the fix really weird:
https://bugzilla.mozilla.org/show_bug.cgi?id=1905039

Fuzzyma added a commit to svgdotjs/svg.js that referenced this issue Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants