npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sortable-draggable-js

v1.1.1

Published

A Javascript Library to make reorderable list

Downloads

15

Readme

sortable-draggable-js.

Streamline your web development with Sortable-Draggable-JS – the ultimate JavaScript library for effortlessly sorting and dragging items on your web page. With its intuitive drag-and-drop functionality, you can easily create custom, reorderable lists that enhance user experience and streamline your workflow.

Demo : https://tahir-sharif.github.io/sortable-draggable-js

Getting Started

Install with NPM:

$ npm install sortable-draggable-js --save

Import into your project:

import Sortable from 'sortable-draggable-js';

Or connect a CDN link (Coming soon)

<script src="https://github.com/tahir150/sortable-draggable-js/edit/master/README.md"></script>

Usage

<div class="sortable-container">
  <div class="sort">
    <span>Hello I am a Element 1</span>
  </div>
  <div class="sort">
    <span>Hello I am a Element 2</span>
  </div>
  <div class="sort">
    <span>Hello I am a Element 3</span>
  </div>
  <div class="sort">
    <span>Hello I am a Element 4</span>
  </div>
</div>
const elements = document.querySelectorAll('.sort');
divsToSort.forEach((item) => {
  const sortable = new Sortable(item);
});

Options

Options object can be assign by giving second argument.

const sortable = new Sortable(item, {
  itemClass: 'item-class', // class applies to every sortable element
  draggingClass: 'dargging', // class will apply when dragging start
  disabledClass: 'disabled', // class will apply if sorting is disable
  zoom: 1, // it is viewport zoom value (if have css zoom property)
  containers: 'sort-container', // comma seperated appendable boxes classes
  fallBackElement: item.classList.contains('fallback') // it is not sortable, it just append this fallback html
    ? `<div class="fallback-element">
         <span>I am fallback</span>
         </div>`
    : null,
  fallBackClone: false, // if will drop a clone of fallback element
  onStart: (startDetail) => {
    // it will trigger when you start sorting
    console.log(startDetail);
  },
  onDrop: (details) => {
    // it will trigger after dropped even it is sorted or not
    console.log(details);
  },
  onSort: (details) => {
    // if element has change or sorted it takes gurantee to trigger after sorting
    console.log(details);
  }
});

itemClass option

It will add a class to every sortable Item

draggingClass option

When Sortable Item starts dragging for sorting, the class will applied and when sorted or cancel sorted, the class will be removed.

disabledClass option

When you disable any element, the class will be applied until you re-enable it.

zoom option

If your body or main container has CSS zoom property or transform scale, you will need to give zoom value which help to drag perfectly.

containers option

It takes css comma seperated classes of div's containers.It will allow the item to drop into zontainer while sorting.

fallBackElement option

It takes HTML DOM object or HTML string, It is fallback Element which will drop into your container.To work with this, container is required. It will not drop the Real sorting Element, It will drop your fallback which you've passed to it.

fallBackClone option

It takes Boolean value (defaults to true). It will drop a clone of your fallback Element.

Contributing

We welcome contributions from everyone!

Bug Reports and Feature Requests

Please use the issue tracker to report any bugs or request new features.

Contributors

Thank you to all the contributors who have helped make this project better! You can find a list of contributors here.