"drag"
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html lang='en' class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/clintonhalpin/pen/eAhsi?limit=all&page=25&q=panel" /> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css'> <style class="cp-pen-styles">html, body { height: 100%; width: 100%; overflow: hidden; } .panel { width: 300px; border-left: 1px solid #999; padding: 20px; position: absolute; right: 0; top: 0; -webkit-transition: margin-right .125s ease; /* For Safari 3.1 to 6.0 */ transition: margin-right .125s ease; float: right; height: 100%; background: white; z-index: 101; } .panel.hidden { margin-right: -400px; } .dragging { box-shadow: 0 0 12px 0px rgba(0,0,0,.8); } .list { list-style-type: none; padding: 10px 0; } .drag-item { display: block; border: 1px solid #999; padding: 20px; margin-bottom: 10px; width: 260px; background: white; border-radius: 3px; } .m0 { margin: 0; } .mt0 { margin-top: 0; } .moving { background: blue; color: white; } #drop-target-one { padding: 20px; background: #CCC; height: 100%; position: absolute; width: 100%; } #drop-target-one.over { background: #999; }</style></head><body> <div id="dd-elements" class="clearfix"> <div class="panel"> <p class="mt0"><strong>Drag some items</strong></p> <div class="drag-item" draggable="true">Element One</div> <div class="drag-item" draggable="true">Element Two</div> <div class="drag-item" draggable="true">Element Three</div> <div class="drag-item" draggable="true">Element Four</div> <div class="drag-item" draggable="true">Element Five</div> </div> <div id="drop-target-one"></div> </div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script >window.onload = function() { var dropZoneOne = document.querySelector('#drop-target-one'); var dragElements = document.querySelectorAll('.panel div'); console.log(dragElements); var elementDragged = null; for (var i = 0; i < dragElements.length; i++) {if (window.CP.shouldStopExecution(1)){break;} // Event Listener for when the drag interaction starts. dragElements[i].addEventListener('dragstart', function(e) { e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text', this.innerHTML); elementDragged = this; $(elementDragged).addClass('dragging'); }); // Event Listener for when the drag interaction finishes. dragElements[i].addEventListener('dragend', function(e) { elementDragged = null; }); } window.CP.exitedLoop(1); ; // Event Listener for when the dragged element is over the drop zone. dropZoneOne.addEventListener('dragover', function(e) { if (e.preventDefault) { e.preventDefault(); } $('.panel').addClass('hidden'); e.dataTransfer.dropEffect = 'move'; return false; }); // Event Listener for when the dragged element enters the drop zone. dropZoneOne.addEventListener('dragenter', function(e) { document.querySelectorAll('.panel').className = "hidden"; this.className = "over"; console.log(this); }); // Event Listener for when the dragged element leaves the drop zone. dropZoneOne.addEventListener('dragleave', function(e) { this.className = ""; }); // Event Listener for when the dragged element dropped in the drop zone. dropZoneOne.addEventListener('drop', function(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); $(elementDragged).removeClass('dragging'); $('#drop-target-one').append(elementDragged); $('.panel').removeClass('hidden'); // Remove the element from the list. document.querySelector('.panel').removeChild(elementDragged); elementDragged = null; return false; }); }; //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: