How can i make a MatDialog draggable / Angular Material

Update since Angular Material 7 You can simply use cdkDrag directive from @angular/cdk/drag-drop dialog.html <h1 mat-dialog-title cdkDrag cdkDragRootElement=”.cdk-overlay-pane” cdkDragHandle> Hi {{data.name}} </h1> Stackblitz Example Previous answer: Since there is no official solution for that, I’m going to write custom directive that will be applied on a dialog title and do all job for us: dialog.html …

Read more

jQuery Drag And Drop Using Live Events

Wojtek’s solution worked perfectly for me. I wound up changing it a tad bit to make it extend jQuery… (function ($) { $.fn.liveDraggable = function (opts) { this.live(“mouseover”, function() { if (!$(this).data(“init”)) { $(this).data(“init”, true).draggable(opts); } }); return this; }; }(jQuery)); Now instead of calling it like: $(selector).draggable({opts}); …just use: $(selector).liveDraggable({opts})

HTML5, JavaScript: Drag and Drop File from External Window (Windows Explorer)

Here is a dead-simple example. It shows a red square. If you drag an image over the red square it appends it to the body. I’ve confirmed it works in IE11, Chrome 38, and Firefox 32. See the Html5Rocks article for a more detailed explanation. var dropZone = document.getElementById(‘dropZone’); // Optional. Show the copy icon …

Read more

Retrieve latitude and longitude of a draggable pin via Google Maps API V3

Either of these work google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = event.latLng.lat(); document.getElementById(“lngbox”).value = event.latLng.lng(); }); google.maps.event.addListener(marker, ‘click’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); }); You might also consider using the dragend event also google.maps.event.addListener(marker, ‘dragend’, function (event) { document.getElementById(“latbox”).value = this.getPosition().lat(); document.getElementById(“lngbox”).value = this.getPosition().lng(); });

Draggable div without jQuery UI

Here’s a really simple example that might get you started: $(document).ready(function() { var $dragging = null; $(document.body).on(“mousemove”, function(e) { if ($dragging) { $dragging.offset({ top: e.pageY, left: e.pageX }); } }); $(document.body).on(“mousedown”, “div”, function (e) { $dragging = $(e.target); }); $(document.body).on(“mouseup”, function (e) { $dragging = null; }); }); Example: http://jsfiddle.net/Jge9z/ I understand that I shall …

Read more