Sortable List Using HTML, CSS, JavaScript with free source code

sortable list,react sortable list,drag and drop sortable list,react-native-sortable-list,bootstrap sortable list,bootstrap drag and drop sortable list,bootstrap 5 sortable list,javascript drag and drop sortable list,jquery sortable list,html sortable list,mui sortable list,sort list alphabetically python,sort list alphabetically,sort list ascending python,sort list alphabetically java,sort list alphabetically c#,sort list alphabetically javascript,sort list angular,sort list apex,sort list ascending java,sort list and get index python,angular sortable list,antd sortable list,aga guideline sortable list,angular sortable list drag and drop,accessible sortable list,angular bootstrap sortable list,angularjs drag and drop sortable list,a sortable list of 80 morning routines,how to make a sortable list in excel,sortable list bootstrap,sort list by value python,sort list by length of string python,sort list by alphabetical order python,sort list by second element python,sort list by alphabetical order,sort list by date java,sort list by index python,sort list by field java,sort list by dictionary value python,blazor sortable list,bootstrap 5 drag and drop sortable list,best react sortable list,bootstrap 4 sortable list,sortable binding list c#,c# datagridview sortable binding list,r sortable bucket list,sortable list css,sortable list c#,sortable list codepen,sort list c#,sort list c# linq,sort list c# by field,sort list cpp,sort list c# by property,sort list comprehension python,sort list comparator java,c# sortable list,confluence sortable list,connected sortable list jquery,create sortable list excel,codepen sortable list,css sortable list,how to create a sortable drop down list in excel,drag and drop sortable list javascript codepen,wp_list_table sortable columns,sortable list drag and drop,sort list descending python,sort list dart,sort list descending java,sort list descending c#,sort list dict python,sort list descending java 8,sort list datetime python,sort list datetime c#,sort list date java,drag and drop sortable list javascript,drag and drop sortable list jquery,drag and drop sortable list react,drag and drop sortable list angular,dnd kit sortable list,devextreme sortable list,datagridview sortable list,drag and drop sortable list codepen,sortable list excel,sort list excel,sort list elements in python,sort list elements in python without function,sort list excel formula,sort list elements in java,sort list elixir,sort list example,sort list elements c#,sort list elements by length,excel sortable list,excel how to make a sortable list,react dnd sortable list example,react sortable list example,react-native-sortable-list example,jquery sortable list example,jquery sortable empty list placeholder,creating a sortable list in excel,jquery sortable drop on empty list,sort list flutter,sort list from smallest to largest python,sort list function python,sort list from highest to lowest python,sort list from smallest to largest java,sort list float python,sort list function java,sort list from a to z,sort list formula excel,sort list function c#,flutter sortable list,framer motion sortable list,framework7 sortable list,form sortable list,jquery sortable remove item from list,which field type in a list is not sortable,sortable list from array,sortable get order,sortable table example,sort list grasshopper,sort list golang,sort list groovy,sort list google docs,sort list gfg,sort list get index python,sort list greatest to least python,sort list gives none,sort list google sheets,sort list generator,jquery ui sortable get sorted list,jquery sortable get list of items,sortable list works with grid as well,bootstrap list group sortable,jquery sortable list get order,sortable receive example,sortable list html,sort list haskell,sort list highest to lowest python,sort list high to low python,sort list hashmap java,sort list highest to lowest c#,sort list high to low,sort list header,sortable horizontal list,sort half list in python,html drag and drop sortable list,html5 sortable list,how to make sortable list,react sortable hoc nested list,react sortable list hoc,jquery sortable horizontal list,sortable list in react,sortable list in jquery,sortable list in javascript,sort list in python,sort list in java,sort list in descending order python,sort list in c#,sort list in descending order java,sort list in alphabetical order python,sort list in java 8,interact js sortable list,ionic sortable list,sortable list in excel,sortable list in confluence,jquery sortable max items in list,sortable list javascript,sortable list jquery,sortable list java,sortable list javascript drag and drop,sort list java,sort list javascript,sort list java 8,sort list java by field,sort list java stream,sort list java comparator,java sortable list,javascript sortable list,jquery bootstrap sortable list,jquery mobile sortable list,javascript drag and drop sortable list project,jquery sortable list save to database,sort list kotlin,sort list key python,sort list kotlin android,sort list key lambda,sort list keep index,sort list keyvaluepair c#,sort list kdb,list.sort(key=len) python,list.sort(key=none reverse=false),kendo angular sortable list,knockout sortable list,kendo sortable list,sort k sorted lists,sort list leetcode,sort list lambda python,sort list lexicographically python,sort list leetcode solution,sort list largest to smallest python,sort list linq,sort list lexicographically java,sort list lowest to highest python,sort list lambda java,sort list length python,laravel sortable list,sortable list library,ls l sort by date,sortable list maker,sortable list material ui,sortable list mui,sort list method python,sort list matlab,sort list map string object in java,sort list meaning,sort list mathematica,sort list max to min python,sort list manually python,material ui sortable list,material sortable list,material design sortable list,making a sortable list in excel,markdown sortable list,make sortable list,sortable list npm,sort list numerically python,sort list numbers python,sort list numpy,sort list numerically,sort list not in place python,sort list numbers,sort list .net,sort list numerically online,npm sortable list,react sortable nested list,react-sortable-list npm,sortable binding list vb.net,sortable nested list jquery,sortable nested list,jquery sortable ordered list numbering,sort list of dictionaries python,sort list online,sort list of tuples,sort list of numbers python,sort list of strings python,sort list of tuples by second element python,sort list of integers java,sort list of strings java,sort list of strings alphabetically python,sort list of tuples by second value,outsystems sortable list,sortable list of s&p 500 companies,onsen ui sortable list,sort this list,sort list python,sort list python descending,sort list python alphabetically,sort list python lambda,sort list python numbers,sort list prolog,sort list python returns none,sort list powershell,sort list python stack overflow,sort list python custom function,primeng sortable list,python sortable list,pure javascript sortable list,php sortable list,jquery ui sortable position in list,pathfinder sortable spell list,s&p 500 sortable list,sorting list questions,sort qdatetime list,sort qt list,sort list power query,sorting list in quickbooks,quasar sortable list,sort qml list,sortable list react,sortable list react native,sortable list react js,sort list r,sort list reverse python,sort list returns none,sort list robot framework,sort list react,sort list randomly python,sort list reverse java,react sortable list drag and drop,react dnd sortable list,rails drag and drop sortable list,react bootstrap sortable list,react js sortable list,rails sortable list,sortable list svelte,sort list string java,sort list string python,sort list string c#,sort list scala,sort list stream java,sort list smallest to largest python,sort list swiftui,sort list swift,sort list second element python,svelte sortable list,swiftui sortable list,sortable list view,streamlit sortable list,sort list typescript,sort list tuples python,sort list tcl,sort list tool,sort list terraform,sort list time complexity,sort list t c#,sort list tuple,sort list to alphabetical order,sort list t,tailwind sortable list,sortable two list,todo_list sortable,sortable list ui,sortable list using jquery ui,sort list using stream java,sort list unity,sort list using lambda python,sort list using for loop in python,sort list using java 8,sort list using comparator,sort list using lambda java,sort list using comparator java 8,unity editor sortable list,jquery ui sortable dynamic list,jquery ui sortable list,jquery ui multiple sortable list,sortable list vanilla js,sort list values python,sort list vb.net,sort list values in dictionary python,sort list vba,sort list view salesforce,sort list view flutter,sort list vuejs,sort list values pandas,vuetify sortable list,vue sortable list,vanilla js sortable list,vue 3 sortable list,vba sortable list,vanilla sortable list,react-native-sortable-list-view,vuetify v-list sortable,sortable list with drag and drop,sortable list wordpress,sort list with lambda python,sort list without built in function python,sort list with comparator java,sort list with key python,sort list with index python,sort list with tuples python,sort list with dicts python,sort list with stream java,wordpress sortable list,wpf sortable list,web sortable list,what is a sortable list,how to use list.sort,sorting list in xslt,x-list,xsl sort alphabetically,python sort list,sort yaml list,sort your list,y sort,sort list zoho creator,sort zipped list python,sort list a-z,sort list a-z python,sort list of zoneddatetime,z sort,sort 0,sortable drop down list excel,sort list of 10 numbers using array in c,sort list of 10 numbers,sort list java 11,python sort list 10 after 9,sort list of 10 numbers algorithm,sort list java 17,sort list leetcode 148,1.) or 1) list,sort list 2d python,sort 2d list by first column,sort 2d list java,sort 2 list python,sort 2d list c#,sort 2 list in java,sort 2 lists based on one python,sort 2 lists of intervals,sort 2 lists based on one c#,sort list by 2 values python,jquery sortable 2 lists,sort two lists,sort multiple lists,sort 3d list python,sort list python 3,three list,three part list,3 part lists,sort_list.c 42,sort_list 42,sortable spell list 5e,sort list of lists,sort list java 6,6 list,6/10 list,6 syllable types sort,6/10 list organized chaos,best word list 7 letters,sort list java 8 stream,sort list java 8 by field,sort list angular 8,sort list ti 84,sort list java 8 lambda,sort numbers in a list,sortable list js,list 9

Social Links

HTML
<!DOCTYPE html>
<!-- Coding By CodingNepal - youtube.com/codingnepal -->
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Drag and Drop Sortable List | CodingNepal</title>
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
    <script src="script.js" defer></script>
  </head>
  <body>
    <ul class="sortable-list">
      <li class="item" draggable="true">
        <div class="details">
          <img src="images/img-1.jpg">
          <span>Kristina Zasiadko</span>
        </div>
        <i class="uil uil-draggabledots"></i>
      </li>
      <li class="item" draggable="true">
        <div class="details">
          <img src="images/img-2.jpg">
          <span>Gabriel Wilson</span>
        </div>
        <i class="uil uil-draggabledots"></i>
      </li>
      <li class="item" draggable="true">
        <div class="details">
          <img src="images/img-3.jpg">
          <span>Ronelle Cesicon</span>
        </div>
        <i class="uil uil-draggabledots"></i>
      </li>
      <li class="item" draggable="true">
        <div class="details">
          <img src="images/img-4.jpg">
          <span>James Khosravi</span>
        </div>
        <i class="uil uil-draggabledots"></i>
      </li>
      <li class="item" draggable="true">
        <div class="details">
          <img src="images/img-5.jpg">
          <span>Annika Hayden</span>
        </div>
        <i class="uil uil-draggabledots"></i>
      </li>
      <li class="item" draggable="true">
        <div class="details">
          <img src="images/img-6.jpg">
          <span>Donald Horton</span>
        </div>
        <i class="uil uil-draggabledots"></i>
      </li>
    </ul>

  </body>
</html>
CSS
/* Import Google font - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #11131e;
}
.sortable-list {
  width: 425px;
  padding: 25px;
  background: #fff;
  border-radius: 7px;
  padding: 30px 25px 20px;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}
.sortable-list .item {
  list-style: none;
  display: flex;
  cursor: move;
  background: #fff;
  align-items: center;
  border-radius: 5px;
  padding: 10px 13px;
  margin-bottom: 11px;
  border: 1px solid #ccc;
  justify-content: space-between;
}
.item .details {
  display: flex;
  align-items: center;
}
.item .details img {
  height: 43px;
  width: 43px;
  pointer-events: none;
  margin-right: 12px;
  object-fit: cover;
  border-radius: 50%;
}
.item .details span {
  font-size: 1.13rem;
}
.item i {
  color: #474747;
  font-size: 1.13rem;
}
.item.dragging {
  opacity: 0.6;
}
.item.dragging :where(.details, i) {
  opacity: 0;
}
JS
const sortableList = document.querySelector(".sortable-list");
const items = sortableList.querySelectorAll(".item");

items.forEach(item => {
    item.addEventListener("dragstart", () => {
        // Adding dragging class to item after a delay
        setTimeout(() => item.classList.add("dragging"), 0);
    });
    // Removing dragging class from item on dragend event
    item.addEventListener("dragend", () => item.classList.remove("dragging"));
});

const initSortableList = (e) => {
    e.preventDefault();
    const draggingItem = document.querySelector(".dragging");
    // Getting all items except currently dragging and making array of them
    let siblings = [...sortableList.querySelectorAll(".item:not(.dragging)")];

    // Finding the sibling after which the dragging item should be placed
    let nextSibling = siblings.find(sibling => {
        return e.clientY <= sibling.offsetTop + sibling.offsetHeight / 2;
    });

    // Inserting the dragging item before the found sibling
    sortableList.insertBefore(draggingItem, nextSibling);
}

sortableList.addEventListener("dragover", initSortableList);
sortableList.addEventListener("dragenter", e => e.preventDefault());

Post a Comment

Previous Post Next Post