I'm looking for a script that will allow a user to pick an image in an HTML page and drag it to a new location while allowing the other page's element to align around it.
While dragging the image should be completely visible (there are many scripts, like TinyMCE and CKeditor) which don't show the image while dragging and only show its new location and the elements around the dragged image after dropping it.
And just to be clear, the image is using the same z-index as the rest of the page (its inline).
I hope I was clear enough, let me know otherwise.
Something like jQuery Masonry? http://masonry.desandro.com/
Related
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.
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!
Edit: Here is the sample demo of what i want: https://codepen.io/AkshayPatil_/pen/oNoPNQE
I'm having an issue, with the Ghost Image / Icon that appears on Drag, for Safari specifically.
In the sample project, I am adding Base64Encoded SVG Images to the DOM. Each time I attempt to drag one of the Images, the Ghost Image gets larger. This behavior doesn't seem to be happening on Chrome.
Ultimately, the drag and drop is meant to allow Users to insert the selected image onto a canvas (using a 3rd Party library). However, the issue occurs even without it.
Not entirely sure what is going on, but any help is most appreciated. I tried using the setDragImage() method in the Drag and Drop API docs, CSS to change the Ghost Image / Icon as outlined here (link: https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/SafariJSProgTopics/DragAndDrop.html) but no luck...
Thanks!
Link to Project:
https://replit.com/#Zeroays/Drag-and-Drop-SIMPLE-TEST#script.js
All the examples that I've seen with draggable elements have a specific destination where the draggable element can be dropped. Is it possible to drop the element anywhere on the screen without specifying the destinations?
I have a map (ThinkGeo) with some specific areas coming from the database. when the user clicks/touches those areas, I'm showing popups with description of those areas. The popup is nothing else than a div that I'm showing and hiding accordingly.
The user wants to be able to move around the popup div on the map. Is this even possible?
Certainly possible and pretty easy with jQuery UI:
$("#elementId").draggable();
And a shim for touch events:
http://touchpunch.furf.com/ which at 584 bytes, is pretty lightweight.
My app uses up to 6 svg images layered to create an interactive image. I have found that I cannot mouseclick on any images below the first.
** Edit. Excess code and text removed.
You can make an element insensitive for mouse events by setting the pointer-events attribute to none (see Tinkerbin):
svg > *{opacity:.5}
In essence I cannot do what I want this way. Stacking embedded images results in only the top layer being clickable by the mouse.
An image map works, with some mucking about.
I created a clear image calling it clearOverlay and gave is a usemap value tying it to my image map.
My imagemap I created using a free online app http://www.image-maps.com which took my image allowed me to create my clickable zones and generated the html for me. After cleaning it up and swapping the href values for onclick functions I added the map to my code.
Next problem was getting it to overlay my existing images. I eventually used style="position:relative; top:-300px" forcing it to sit squarely on my image. I'm sure there must be a better way, but at this point that worked for me.
For anyone else doing this don't forget to either place the clearOverlay last in your image list or set the css z-index to higher than everything else to make sure it is sitting on top.
So I now have a stacked svg image, where I can manipulate each svg according to where the user clicks. Its only taken me 5 days! I'm kinda over this coding by yourself lark.
** My image map above will not scale to different sized screens. The next time I try this, I will experiment using a transparent svg with fill zones where I wish to click.
I have a textbox, a div, and an image.
Do we have any way to do like this:
When I drag that image into the div. (The image don't need to move, just like we left click on it, and drag it to anywhere, but it never move.)
The div show the image. (Duplicated 1 image into the div)
The text show URL of that image.
Do you have any idea or article(s) on doing this thing?
I've never coded drag drop in my life, but I know Step 2 is just set HTML for the div, and Step 3 is just get image src. However, on Step 1, how do I know when "the image into the div and the mouse release?"
I know jQuery UI, it's not the dragable from jQuery UI, cause the draggable makes object move. I don't want it move. Can you try click on any image on this stackoverflow website, or any link. Then you hold your mouse and drag it. Try drag a link into the search box at top, and you get the link. Thats what I want. Not the dragable of jQuery UI to make the object move.
You can do all of this with the dragable feature in jQuery. I noticed in a comment you mentioned that you don't believe this will work because it actually moves the image but there are more than just the default options! Take a look at the clone helper attribute.
Here's about as close of an example as there is and it sounds like you already know how to handle the rest (getting the src attribute, etc.).
http://jqueryui.com/demos/droppable/#method-option
JQuery draggable allows you to leave the original in its place while dragging through the use of Helpers. See this url and try dragging the top grey boxes around. The two on the right use helpers, leaving the original in place.
http://www.jqueryui.com/demos/draggable/#visual-feedback
Using this in conjuntion with the link Artsemis provided will do the trick
Dragging an image into your address bar is a function of the web browser, not JS or the page you are viewing. You will want to use jquery draggable or something like it.