Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the image that browser generates when we drag an element. Here is the simple example why I want to do this.

https://i.stack.imgur.com/dt4ZG.png[^]

In the above image the two videos placed inside the black div like picture-in-picture. The black div is able to drag & drop. When I drag the black div the browser generates the draggable translucent image like in above picture.

In code implementation I am using dataTransfer setData & getData method to access dragged image. When I drop image and use dataTransfer.getData gives the dragged div ID and having only black background. I need the actual dragged image to store in state in the form of URL to use in application.

How can I do this without using any external libraries? I know the HTML2Canvas library generates screenshots like browser do. But is there any way to use/store browsers dragged image?

Thank you!

What I have tried:

Demo example: https://codepen.io/AkshayPatil_/pen/oNoPNQE[^]
Posted
Updated 28-Feb-22 0:35am
v2
Comments
Andre Oosthuizen 25-Feb-22 7:23am    
Please show us your code to establish where your problem lies.
Akshay_ 25-Feb-22 8:30am    
Hello mate, thank you very much for your replay. Here is the sample example of drag & drop i made.
https://codepen.io/AkshayPatil_/pen/oNoPNQE
Hope you will understand what i wanted. Fill free to ask if you have any query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900