Skip to content

Instantly share code, notes, and snippets.

@nischalshrestha
Created January 13, 2021 19:32
Show Gist options
  • Save nischalshrestha/a74c4aea08418f65a954e28bd1a89ba0 to your computer and use it in GitHub Desktop.
Save nischalshrestha/a74c4aea08418f65a954e28bd1a89ba0 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/voroqedeqo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body {
padding: 10px;
}
.glyphicon-move {
cursor: move;
cursor: -webkit-grabbing;
}
</style>
</head>
<body>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<!-- Latest Sortable -->
<script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"></script>
<div id="coolElement"></div>
<!-- List with handle -->
<div id="listWithHandle" class="list-group">
<div class="disabled list-group-item">
<span class="badge">1</span>
<span class="glyphicon glyphicon-move" aria-hidden="true"></span>
Best of both worlds!
</div>
<div class="list-group-item">
<span class="badge">14</span>
<span class="glyphicon glyphicon-move" aria-hidden="true"></span>
Drag me by the handle
</div>
<div class="list-group-item">
<span class="badge">2</span>
<span class="glyphicon glyphicon-move" aria-hidden="true"></span>
You can also select text
</div>
<div class="disabled list-group-item">
<span class="badge">1</span>
<span class="glyphicon glyphicon-move" aria-hidden="true"></span>
Best of both worlds!
</div>
</div>
<script id="jsbin-javascript">
// List with handle
Sortable.create(listWithHandle, {
handle: '.glyphicon-move',
animation: 150,
filter: ".disabled",
onMove: function (evt) {
return evt.related.className.indexOf('disabled') === -1;
}
});
</script>
<script id="jsbin-source-css" type="text/css">body {
padding: 10px;
}
.glyphicon-move {
cursor: move;
cursor: -webkit-grabbing;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">// List with handle
Sortable.create(listWithHandle, {
handle: '.glyphicon-move',
animation: 150,
filter: ".disabled",
onMove: function (evt) {
return evt.related.className.indexOf('disabled') === -1;
}
});</script></body>
</html>
body {
padding: 10px;
}
.glyphicon-move {
cursor: move;
cursor: -webkit-grabbing;
}
// List with handle
Sortable.create(listWithHandle, {
handle: '.glyphicon-move',
animation: 150,
filter: ".disabled",
onMove: function (evt) {
return evt.related.className.indexOf('disabled') === -1;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment