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

Difficulty when transforming grid and position #123

Open
Bewinxed opened this issue Feb 25, 2023 · 5 comments
Open

Difficulty when transforming grid and position #123

Bewinxed opened this issue Feb 25, 2023 · 5 comments

Comments

@Bewinxed
Copy link

Thank you for this library

I’m trying to make a CSS grid where people can drag widgets around, I’m storing each widgets dimension and coordinates and when generating the grid I populate each widget position and span Using these values.

I’m using use draggable on the widget div, I’m using the grid option with the same cell size in order for the drag snapping to match.

And using the transform property to Modify the grid row and the grid column.

The problem is that when I drag something the first time it's fine, but when I drag it the 2nd time, the offset starts from the last offset instead of 0.

How can I mitigate this?

Thanks!

@PuruVJ
Copy link
Owner

PuruVJ commented Mar 20, 2023

Can you reproduce this bug on something like Svelte REPL/Stackblitz?

@santiagopuentep
Copy link

I found the same issue when I was modifying the library. The internal offset is not clear what it represents and I think there's a calculation error when returning the value after the second drag.

@laotala828
Copy link

First, thank you for this library!

I am facing the same issue. I am mimicking the iOS drag from edge gesture - I will let users drag a page, if the offsetX is smaller than screenWidth/2 when drag ends it will bounce back. For example, if the screen width is 400, and the first drag ends at offsetX=100, the page will bounce back as expected. If I try a second drag, the offsetX will start from 100 instead of starting from 0.

Screen.Recording.2023-06-08.at.19.11.21.mov

@cmjoseph07
Copy link

cmjoseph07 commented Aug 3, 2023

@PuruVJ

Found hacky workaround to this issue, simply reset position and do not try to translate/transform to get back to default position. Seems to work fine this way.

let dragOptions: DragOptions = {
		bounds: '.draggable-boundary',
		position: {x: 0 , y: 0},
		onDragEnd: ({ offsetX, offsetY, rootNode, currentNode }) => {
      const dateAtPoint = calendarInstance.dateFromPoint(lastMousePosition.x, lastMousePosition.y);
			console.log(currentNode)

			if (dateAtPoint === null) {
				dragOptions.position = { x: 0, y: 0 };
			}
    },
  };

@BraveDevelopment
Copy link

BraveDevelopment commented Aug 31, 2024

Is there a fix in the work? Because this bug makes the whole library useless for me. 😞

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

6 participants