Drag n Drop
How do I make an drag n drop?
Http://www.html5rocks.com/en/tutorials/dnd/basics/(restart at 'The DataTransfer object'). What is a drag n drop? How do you make a drag n drop? This script and codes were developed by Martin Baillie on 25 January 2023, Wednesday.
Drag n Drop - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Drag n Drop</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="columns"> <div class="column" draggable="true"><header>A</header></div> <div class="column" draggable="true"><header>B</header></div> <div class="column" draggable="true"><header>C</header></div>
</div> <script src="js/index.js"></script>
</body>
</html>
Drag n Drop - Script Codes CSS Codes
/* Prevent the text contents of draggable elements from being selectable. */
[draggable] { -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; user-select: none; /* Required to make elements draggable in old WebKit */ -khtml-user-drag: element; -webkit-user-drag: element;
}
.column { height: 150px; width: 150px; float: left; border: 2px solid #666666; background-color: #ccc; margin-right: 5px; -webkit-border-radius: 10px; -ms-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; -webkit-box-shadow: inset 0 0 3px #000; -ms-box-shadow: inset 0 0 3px #000; box-shadow: inset 0 0 3px #000; text-align: center; cursor: move;
}
.column header { color: #fff; text-shadow: #000 0 1px; box-shadow: 5px; padding: 5px; background: -moz-linear-gradient(left center, rgb(0,0,0), rgb(79,79,79), rgb(21,21,21)); background: -webkit-gradient(linear, left top, right top, color-stop(0, rgb(0,0,0)), color-stop(0.50, rgb(79,79,79)), color-stop(1, rgb(21,21,21))); background: -webkit-linear-gradient(left center, rgb(0,0,0), rgb(79,79,79), rgb(21,21,21)); background: -ms-linear-gradient(left center, rgb(0,0,0), rgb(79,79,79), rgb(21,21,21)); border-bottom: 1px solid #ddd; -webkit-border-top-left-radius: 10px; -moz-border-radius-topleft: 10px; -ms-border-radius-topleft: 10px; border-top-left-radius: 10px; -webkit-border-top-right-radius: 10px; -ms-border-top-right-radius: 10px; -moz-border-radius-topright: 10px; border-top-right-radius: 10px;
}
.column.over { border: 2px dashed #000;
}
Drag n Drop - Script Codes JS Codes
if (Modernizr.draganddrop) { console.log(1);
} else { console.log(2);
}
function handleDragStart(e) { this.style.opacity = '0.4'; // this / e.target is the source node.
}
function handleDragOver(e) { if (e.preventDefault) { e.preventDefault(); // Necessary. Allows us to drop. } e.dataTransfer.dropEffect = 'move'; return false;
}
function handleDragEnter(e) { // this / e.target is the current hover target. this.classList.add('over');
}
function handleDragLeave(e) { this.classList.remove('over'); // this / e.target is previous target element.
}
function handleDrop (e) { // this / e.target is current target element. if (e.stopPropogation) { e.stopPropogation(); // stops the browser from redirecting } return false;
}
function handleDragEnd(e) { // this / e.target is the source node. [].forEach.call(cols, function (col) { col.classList.remove('over'); });
}
var cols = document.querySelectorAll('#columns .column');
[].forEach.call(cols, function(col) { col.addEventListener('dragstart', handleDragStart, false); col.addEventListener('dragenter', handleDragEnter, false); col.addEventListener('dragover', handleDragOver, false); col.addEventListener('dragleave', handleDragLeave, false); col.addEventListener('drop', handleDrop, false); col.addEventListener('dragend', handleDragEnd, false);
});
Developer | Martin Baillie |
Username | martin42 |
Uploaded | January 25, 2023 |
Rating | 3 |
Size | 2,594 Kb |
Views | 4,048 |
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!
Name | Size |
Accessible Tabs | 0 Kb |
More Array Methods | 2,327 Kb |
Shuffle List Animation | 2,362 Kb |
A Pen by Martin Baillie | 2,210 Kb |
Flexbox | 1,774 Kb |
URL Compare | 2,519 Kb |
JS Interview Questions | 7,121 Kb |
M-test | 1,250 Kb |
Square Osc | 2,616 Kb |
Q try catch timeout | 1,758 Kb |
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!
Name | Username | Size |
FCC Portfolio | Cmwebby | 4,304 Kb |
Client-side Email Validation | Collizo4sky | 1,538 Kb |
Base-Style | Daniel_gooss | 2,614 Kb |
CSSOff 2013 Submission | Codewunder | 14,766 Kb |
Draggable directive | YahyaKacem | 2,277 Kb |
Banner Ad | Raquellorenzana | 4,172 Kb |
Pure CSS Torch Light | Juliendargelos | 2,727 Kb |
No Vacancy 404 CSS Only | Sethkontny | 0 Kb |
Algorithm practice | Abensur | 5,620 Kb |
Basecamp 3 Document | Lachlanjc | 3,811 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!