Forked from Thomas Eschemann's Pen Nested drag & drop using dragula.js.
Created
April 20, 2020 11:57
-
-
Save lucideuclid/953921ea16cd1fa60502fafb3b3da999 to your computer and use it in GitHub Desktop.
Nested drag & drop using dragula.js
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
<div class="container"> | |
<div class="bloc bloc--first"> | |
<div class="bloc--inner"></div> | |
</div> | |
<div class="bloc bloc--second"> | |
<div class="bloc--inner"></div> | |
</div> | |
</div> |
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
(function() { | |
dragula([document.querySelector('.container')], { | |
moves: function(el, container, handle) { | |
return !handle.classList.contains('bloc--inner'); | |
} | |
}); | |
dragula([].slice.apply(document.querySelectorAll('.bloc')), { | |
direction: 'horizontal' | |
}); | |
})(); |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="https://rawgit.com/bevacqua/dragula/master/dist/dragula.min.js"></script> |
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
html, body { | |
height: 100%; | |
} | |
body { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
flex-flow: row wrap; | |
} | |
.bloc { | |
width: 400px; | |
height: 200px; | |
margin-bottom: 20px; | |
padding: 20px; | |
font-size: 0; | |
} | |
.bloc--first { | |
background: red; | |
} | |
.bloc--second { | |
background: green; | |
} | |
.bloc--inner { | |
display: inline-block; | |
width: calc((100% - 20px) / 2); | |
height: 100%; | |
background: blue; | |
margin-right: 20px; | |
&:last-of-type { | |
margin: 0; | |
} | |
} |
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
<link href="https://rawgit.com/bevacqua/dragula/master/dist/dragula.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment