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

ngx-sortable

v2.1.0

Published

An angular 4 and above component for sorting list supporting drag and drop sort.

Downloads

8,858

Readme

ngx-sortable

GitHub license npm Codecov branch npm GitHub top language GitHub code size in bytes GitHub issues GitHub closed issues GitHub contributors

ngx-sortable an angular 4 and above component for sorting list supporting drag and drop sort.

Features

  • Custom template
  • Customizable
  • Drag and drop sorting
  • Use keyboard to sort
  • Remove elements

Examples

Installation

  • npm install ngx-sortable

Using with webpack and tsc builds/ angular-cli builds

  • import NgxSortableModule into your app.module;
import { NgxSortableModule } from 'ngx-sortable'
  • add NgxSortableModule to the imports of your NgModule:
@NgModule({
  imports: [
    ...,
    NgxSortableModule
  ],
  ...
})
class YourModule { ... }
  • use <ngx-sortable></ngx-sortable> in your templates to add sortable list in your view

Deprecated

    <ngx-sortable [items]="items" [name]="'List'" (listSorted)="listOrderChanged($event)">
        <ng-template let-item>
            <div class="sortable-list-item">
                {{item}}
            </div>
        </ng-template>
    </ngx-sortable>

v2.0.0 onwards use below

    <ngx-sortable [items]="items" [name]="'List'" (listSorted)="listOrderChanged($event)">
        <ng-template let-item="item">
            <div class="sortable-list-item">
                {{item}}
            </div>
        </ng-template>
    </ngx-sortable>

Where content inside <ng-template> </ng-template> is the template that will be used for displaying list items. Also the class can be named accordingly this is just an example. Create a class and add it to your root style.css

Notice the difference in accessing the item in above two examples. Also from v2.0.0 onwards index of the item is also available in the template similar to let-item="item" use let-i="index" and i will be the index variable available in the template.

Config

Input

  • items: any[] - array of list items.
  • name: string - List name that will be shown in the header.
  • listStyle: any - list styles such as height, width.
  • showHeader: boolean - flag to hide / show header default is true
  • removeOnDropOutside: boolean - flag to enable remove items by dragging and dropping them outside the list. Default is false
  • arrowKeySort: boolean - flag to enable sort using keyboard arrow keys. Example: Ctrl + ArrowDown moves item down
  • commandKey: CommandKey - key type to use along with arrow keys for sorting e.g. ctrlKey/altKey. Default is ctrlKey
enum CommandKey {
  CtrlKey = "ctrlKey",
  ShiftKey = "shiftKey",
  Altkey = "altKey",
  MetaKey = "metaKey",
}
listStyle = {
        width:'300px', //width of the list defaults to 300
        height: '250px', //height of the list defaults to 250
      }

Output

  • listSorted($event): Event - when list is sorted emits listSorted event with updated order

Where $event is the sorted list

  • dragStart($event): Event - emitted when an item is seleceted and starts dragging

Where $event:{ event: Javascript event, itemIndex: current item index, newIndex: -1, item: selected item}

  • dropped($event): Event - emitted when an item is dropped at the new index

Where $event:{ event: Javascript event, itemIndex: current item index, newIndex: new item index, item: selected item}

  • moveDown($event): Event - emitted when an item is moved down in the list using the sort arrows

Where $event:{ itemIndex: current item index, newIndex: new item index, item: selected item}

  • moveUp($event): Event - emitted when an item is moved up in the list using sort arrows

Where $event:{ itemIndex: current item index, newIndex: new item index, item: selected item}

  • remove($event): Event - emitted when an item is removed from the list by dropping out, only works when removeOnDropOutside is set to true

Where $event:{ itemIndex: current item index, item: selected item}

Help Improve

Found a bug or an issue with this? Open a new issue here on GitHub.

Contributing to this project

Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing.