Fiddling with Drag and Drop

Size
2,286 Kb
Views
20,240

How do I make an fiddling with drag and drop?

This is just a test. Nothing fancy. What is a fiddling with drag and drop? How do you make a fiddling with drag and drop? This script and codes were developed by Shayne Trosdahl on 18 November 2022, Friday.

Fiddling with Drag and Drop Previews

Fiddling with Drag and Drop - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Fiddling with Drag and Drop </title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <button draggable='true'>Button</button>
<div draggable='true' style="width: 60px; height: 60px; background: tomato;"></div> <script src="js/index.js"></script>
</body>
</html>

Fiddling with Drag and Drop - Script Codes CSS Codes

@import "compass/css3";

Fiddling with Drag and Drop - Script Codes JS Codes

// Get the body and get the Viewport width and height
var body	= document.querySelector('body');
vWidth	= document.width;
vHeight	= document.height;
// Set the body width & height - 20px
body.style.width = vWidth - 20 + 'px';
body.style.height = vHeight - 20 + 'px';
// Give the body a black border
body.style.border = 'black 1px solid';
// Automatically run this here
var clickPosition = (function() {	// Set vars to be used in just a moment var myX	= ''; var myY	= ''; var thing = ''; // Multi browser support for xy coords function moveStart(e) {	thing = e.target; thing.setAttribute('draggable', true); thing.style.position = 'absolute'; myX	= e.offsetX === undefined ? e.layerX : e.offsetX; myY	= e.offsetY === undefined ? e.layerY : e.offsetY; } // Prevent browser default events from screwing this up function moveDragOver(e) { e.preventDefault(); } // Set new xy coords function moveDrop(e) { e.preventDefault(); thing.style.left	= e.pageX - myX + 'px'; thing.style.top	= e.pageY - myY + 'px'; } // Events to trigger functions above document.querySelector('body').addEventListener('dragstart', moveStart, false); document.querySelector('body').addEventListener('dragover', moveDragOver, false); document.querySelector('body').addEventListener('drop', moveDrop, false);
})();
Fiddling with Drag and Drop - Script Codes
Fiddling with Drag and Drop - Script Codes
Home Page Home
Developer Shayne Trosdahl
Username Trozdol
Uploaded November 18, 2022
Rating 3
Size 2,286 Kb
Views 20,240
Do you need developer help for Fiddling with Drag and Drop?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Shayne Trosdahl (Trozdol) Script Codes
Create amazing marketing copy with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!