neodrag icon indicating copy to clipboard operation
neodrag copied to clipboard

adjusting on window resize

Open braebo opened this issue 3 years ago • 4 comments

Draggables don't seem to react to window resize events.

They can become lost outside of the boundary because of this.

Not sure if this is because of something I've done on my end though.

braebo avatar Oct 06 '22 21:10 braebo

I've thought about this, and not sure how I want to tackle this. If you take draggable outside the svelte REPL examples and leave them here, they stay there. That much is predictive.

But if you have set the bounds, and resize causes it to go out of the bounds, then that is a possible issue. Should work on that. Thanks for letting me know. Will be using resizeObserver for this

PuruVJ avatar Oct 07 '22 07:10 PuruVJ

I had a similar problem, and I wanted to use drag to change the position without transform/translate. If we're able to do that, I could imagine using the left/top positioning properties to position it as a % of the parent. (The draggable elements would be absolutely positioned on a parent that scales with the window size.)

@PuruVJ , would you be open to exposing a custom style function? Like the custom transform that currently exists.

patriciatiffany avatar Feb 25 '23 19:02 patriciatiffany

I had a similar problem, and I wanted to use drag to change the position without transform/translate. If we're able to do that, I could imagine using the left/top positioning properties to position it as a % of the parent. (The draggable elements would be absolutely positioned on a parent that scales with the window size.)

@PuruVJ , would you be open to exposing a custom style function? Like the custom transform that currently exists.

You can do that with custom transform. If you don't return anything, no styles will be applied. You can directly apply rootNode.style.top in customTransform

PuruVJ avatar Feb 26 '23 02:02 PuruVJ

Ah, I missed that, thanks. That's perfect-- it works!

patriciatiffany avatar Feb 26 '23 23:02 patriciatiffany