Created
July 27, 2012 23:40
-
-
Save ahmetvurgun/3191070 to your computer and use it in GitHub Desktop.
Untitled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.over { | |
border: 2px dashed #000; | |
width:200px; | |
heigt:200px; | |
display:block; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="column"> | |
<div class="over" draggable="true"><header>A</header></div> | |
<div class="over" draggable="true"><header>B</header></div> | |
<div class="over" draggable="true"><header>C</header></div> | |
</div> | |
<script> | |
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'; // See the section on the DataTransfer object. | |
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. | |
alert("handleDragLeave"); | |
} | |
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); | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"html"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment