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

Draggable animation grabs pixels of element above it #1276

Closed
tscizzle opened this issue Jan 29, 2018 · 18 comments
Closed

Draggable animation grabs pixels of element above it #1276

tscizzle opened this issue Jan 29, 2018 · 18 comments

Comments

@tscizzle
Copy link

Searched the issues and don't see this one already.

sortable-grab-too-much

The dark rectangles are the draggable elements.

Notice that the orange paragraph above has a piece of it dragging around.

And then when dragging the bottom one, it grabs a piece of the draggable element (dark rectangle) above it.

I don't have a jsbin of it, just curious if the developers, or any other users, have seen this before. Seems pretty recognizable, if it has indeed ever happened before.

@zanedev
Copy link

zanedev commented Jan 30, 2018

Yeah I'm seeing it. Not sure what the solution is yet. Seems to be related to css positioning. Will post back if I figure it out.

@stguitar
Copy link

I am also seeing this issue.

@zanedev
Copy link

zanedev commented Jan 30, 2018

So I fixed it by removing or tweaking the values for any absolute positioned elements inside the draggable item. If you have absolutely positioned elements with borders it causes issues.

@stguitar
Copy link

i have also since resolved my issue but i am doing this within the context of material design and angular 5. my issue was having the draggable element to have the 'matRipple' css class, which must be doing something similar to what you found.

in the end, i didnt need that class for my use case anyway so I simply removed it.

@tscizzle
Copy link
Author

Hmm, I have a list of draggable items that exhibits this same behavior, but doesn't have any absolute positioned elements in it. So I think there's at least another thing at play.

@zanedev
Copy link

zanedev commented Jan 31, 2018 via email

@zanedev
Copy link

zanedev commented Jan 31, 2018 via email

@markjanzer
Copy link

I had this same error on Chrome (but not on FireFox). There was an element absolutely positioned inside of the draggable element with visibility: hidden; that was forcing the ghost element to render larger than necessary. I solved it by setting the max-height of the absolutely positioned element to 0 when it is not visible.

@zanedev
Copy link

zanedev commented Feb 21, 2018

I fixed it for our use case by using forceFallBack: true which isn't ideal but works for now. There is a drawback to forcing the fallback however, I noticed that the positioning/offset of the dragged item from the mouse can get off slightly in certain situations.

I'm pretty sure this is a chrome bug, apparently whatever you are dragging using the native drag and drop apis needs to be completely visible in the browser with nothing covering it.

@indreksiitan
Copy link

I'm experiencing the same problem. But it only appears on Safari (11.0.3) on a Mac - Chrome (65.0.3325.162) and Firefox (58.0.2) on exactly the same site are OK.

@alexblunck
Copy link

The issue came up when upgrading from sortable 1.6.1 -> 1.7.0 & only appeared in Chrome 64+

I managed to fix it by setting position & transform on the sortable elements

position: relative;
transform: translateZ(0);

@indreksiitan
Copy link

In my case (1.7.0, Safari) it unfortunately doesn't seem to help.

@alexbainbridge
Copy link

I have used this on a list that includes a series of embedded dynamic maps (that have many absolute positions to make them work)

.sortable-chosen, .sortable-chosen.sortable-ghost { z-index: 10000; } .sortable-ghost { background-color: rgba(254, 245, 204, 0.35); }

Which at least hides the extra pixels (z-index) and the colouring of where you will "land" the item being dragged helps users know when to let go.

However my remaining problem is that the pointer calculates the centre including the hidden (extra) content.... i.e. off centre by a long way. However, progress :)

[Above works better on Chrome]

@zanedev
Copy link

zanedev commented Jun 19, 2018

@alexblunck's fix worked for me, much better solution than force fallback

@indreksiitan
Copy link

Ran into this issue again and now at least figured out what happens. The draggable row has icon buttons, which in turn have tooltips on hover. On Safari, the ghost dimensions are calculated with the tooltips shown, so it grabs some extra from above.

@indreksiitan
Copy link

.. and with the help of @markjanzer comment from Feb 6 now solved it with:

[data-tooltip]:after { max-height: 0; } [data-tooltip]:hover:after { max-height: inherit; }

@owen-m1
Copy link
Member

owen-m1 commented Dec 16, 2018

Solved in 1.8.0-rc1 using @alexblunck's solution

@owen-m1 owen-m1 closed this as completed Dec 16, 2018
@SysuCai
Copy link

SysuCai commented Mar 28, 2019

This solution doesn't work on chrome 47

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

9 participants