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

Question: How to make square corners transparent when dragging rounded-corner element? #788

Closed
nottoseethesun opened this issue Jun 6, 2017 · 10 comments

Comments

@nottoseethesun
Copy link

nottoseethesun commented Jun 6, 2017

This issue does not happen on Firefox and Safari. Perhaps it is a bug related to Chrome or any possible Chrome specific react-dnd code (if there is any), as it only happens there.

I have a draggable element with rounded corners, and when it is dragged, the square corners of the element show up in a light grey color, different from the assigned background color of the element.

I'd like that to go away, so just the element with its rounded corners shows up.

Is there something that can be done to turn this off? Such as with a ghost image that may be being applied?

@theTechie
Copy link
Member

theTechie commented Jun 7, 2017 via email

@nottoseethesun
Copy link
Author

nottoseethesun commented Jun 7, 2017

Thanks - not using CustomDragLayer; everything is plain.

On the screenshot, not possible on that unfortunately but I can describe better: The draggable is a square div about an inch on each side, with rounded corners (border radius 10px). The draggable, when dragged looks normal in all respects (it still has its rounded corners and proper color) except for one thing: Each of the four unrounded corners appear as well, as they would if there were no border radius rounding on the element, except that the color of the unrounded portion is that of the parent element of the draggable (the parent element where it was dragged from). So each rounded corner is unhappily accompanied, on Chrome browser only (not Firefox or Safari), with a little "hat" that is the rest of the surface area of the div as it would be without the rounded corners.

It is almost as if Chrome is snapshotting the div and holding that in memory. Earlier with this I actually had a problem with endDrag and when I clicked outside of the web browser on the desktop, I could see the draggable just as described.

I tried setting WebkitTapHighlightColor (React identifier format) to transparent, but that did not fix this.

@theTechie
Copy link
Member

theTechie commented Jun 7, 2017 via email

@nottoseethesun
Copy link
Author

Thanks - I tried the border-radius on that example and indeed you are correct. However the reason it looks correct is because the entire work area is the same background color. Once an html element native ghost image in Chrome is dragged onto a different background color, those corners do show up. In my case, I do have that situation. It can be worked around though successfully by specifying a ghost image.

@douweknook
Copy link

Ran into this same issue. Ultimately managed to fix it by adding transform: 'translate(0, 0)' to the node I wanted as my drag preview. Got some insights from this page: https://kryogenix.org/code/browser/custom-drag-image.html as it shows examples where the corners are there and where they are gone.

@densk1
Copy link

densk1 commented Mar 27, 2018

@douweknook thanks for this. Finding a solution has taken a substantial amount of time.

@ariellevitsky
Copy link

ariellevitsky commented May 31, 2018

@douweknook awesome solution!

A simple css implementation would look something like:

	.sortable-chosen {
		transform: translate(0, 0);
	}

I would chain the .sortable-chosen to your sortable element class to ensure that the style is not globally applied. For example, if your sortable element class is "item" then use .item.sortable-chosen instead!

@a-m-dev
Copy link

a-m-dev commented Aug 26, 2018

@douweknook YAY....... thank you , it solved the problem even in pure javaScript tank you

@danny-andrews
Copy link

@douweknook You're a gentleman and a scholar. This worked for fixing border radius issue, but it still crops off box shadow. Note: this works properly in Firefox.

bug

@danny-andrews
Copy link

I created a separate issue for this, for anyone interested. #2762

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

7 participants