A Pen by Joe Watkins on CodePen.
Created
February 19, 2014 03:37
-
-
Save joe-watkins/9085627 to your computer and use it in GitHub Desktop.
A Pen by Joe Watkins.
This file contains 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
<h3>Feedback on activating draggable:</h3> | |
<div data-draggable="true"> | |
<p>Drag me</p> | |
</div> | |
<div data-droppable="true"> | |
<p>Drop here</p> | |
</div> | |
<p class="output"></p> |
This file contains 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
$("[data-draggable='true']").draggable({ | |
revert : 'invalid' | |
}); | |
$("[data-droppable='true']").droppable({ | |
accept: "[data-draggable='true']", | |
activeClass: "ui-state-default", | |
drop: function(event,ui) { | |
$(this).addClass( "ui-state-highlight" ) | |
.find("p") | |
.html("Dropped!"); | |
console.log(event); | |
} | |
}); |
This file contains 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
[data-draggable='true'] { | |
width: 90px; | |
height: 90px; | |
padding: 0.5em; | |
background:#eee; | |
float: left; | |
margin: 10px 10px 10px 0; | |
border-radius:90px; | |
cursor:move; | |
text-align:center; | |
} | |
[data-droppable='true'] { | |
width: 120px; | |
height: 120px; | |
padding: 0.5em; | |
background:#ddd; | |
float: left; | |
margin: 10px; | |
} | |
.ui-state-default { | |
border:dashed 2px red; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment