New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ngx-virtual-sortable

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-virtual-sortable

[![npm](https://img.shields.io/npm/v/ngx-virtual-sortable.svg)](https://www.npmjs.com/package/ngx-virtual-sortable) [![npm](https://img.shields.io/npm/dm/ngx-virtual-sortable.svg)](https://www.npmjs.com/package/ngx-virtual-sortable) [![Software License](h

latest
Source
npmnpm
Version
13.1.2
Version published
Weekly downloads
9
-59.09%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-virtual-sortable

npm npm Software License

A virtual scrolling list component that can be sorted by dragging

Live demo

Simple usage

npm i ngx-virtual-sortable

virutal-list.module.ts

...
import { VirtualListModule } from 'ngx-virtual-sortable';

@NgModule({
  declarations: [
    ...
  ],
  imports: [
    ...
    VirtualListModule
  ],
  providers: []
})
export class ListModule { }

virutal-list.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'virutal-list',
  template: `
    <div #scroller>
      <div
        virtual-list
        [scroller]="scroller"
        [dataKey]="'id'"
        [keeps]="30"
        [(ngModel)]="list"
        (ngModelChange)="onChange($event)"
      >
        <ng-template let-item let-index="index">
          <div class="list-item">
            <span>{{ index }}</span>
            <p>{{ item.text }}</p>
          </div>
        </ng-template>
      </div>
    </div>
  `,
  styles: [],
})
export class AppComponent {
  public list = [
    { id: 'a', text: 'aaa' },
    { id: 'b', text: 'bbb' },
    { id: 'c', text: 'ccc' },
    ...
  ];

  onChange(data) {
    // the data changes after the dragging ends
  }
}

EventEmitters

EventDescription
onTopScrolled to top of scroll element
onBottomScrolled to bottom of scroll element
onDragElement dragging started
onDropElement dragging is completed
onRangeChangeList rendering range changed

Props

Required Props

PropTypeDescription
data-keyStringThe unique identifier of each piece of data, in the form of 'a.b.c'
scrollerHTMLElement | DocumentVirtual list scrolling element

Optional Props

Commonly used

PropTypeDefaultDescription
keepsNumber30The number of lines rendered by the virtual scroll
sizeNumber-The estimated height of each piece of data, it will be automatically calculated
handleFunction/String-Drag handle selector within list items
groupObject/String-string: 'name' or object: { name: 'group', put: true/false, pull: true/false/'clone', revertDrag: true/false }
directionvertical | horizontalscroll direction
lockAxisx | y-Axis on which dragging will be locked
tableModeBooleanfalseUsing Virtual Lists in Tabular Mode
keepOffsetBooleanfalseWhen scrolling up to load data, keep the same offset as the previous scroll
debounceTimeNumber0debounce time on scroll
throttleTimeNumber0throttle time on scroll

Uncommonly used

PropTypeDefaultDescription
wrapperHTMLElement-Virtual list wrapper
bufferNumberMath.round(keeps / 3)Buffer size to detect range change
sortableBooleantrueAllow Sorting by Dragging
draggableString[role="item"]Specifies which items inside the element should be draggable
disabledBooleanfalseDisables the sortable if set to true
animationNumber150Animation speed moving items when sorting
autoScrollBooleantrueAutomatic scrolling when moving to the edge of the container
scrollSpeedObject{ x: 10, y: 10}Vertical&Horizontal scrolling speed (px)
scrollThresholdNumber55Threshold to trigger autoscroll
delayNumber0Time in milliseconds to define when the sorting should start
delayOnTouchOnlyBooleanfalseOnly delay on press if user is using touch
appendToBodyBooleanfalseAppends the ghost element into the document's body
dropOnAnimationEndBooleantrueWhether to trigger the drop event when the animation ends
ghostClassString''The class of the mask element when dragging
ghostStyleObject{}The style of the mask element when dragging
chosenClassString''The class of the selected element when dragging
placeholderClassString''Class name for the drop placeholder

Public Methods

MethodDescription
getSize(key)Get the size of the current item by unique key value
getOffset()Get the current scroll height
getClientSize()Get wrapper element client viewport size (width or height)
getScrollSize()Get all scroll size (scrollHeight or scrollWidth)
scrollToTop()Scroll to top of list
scrollToBottom()Scroll to bottom of list
scrollToKey(key)Scroll to the specified data-key position
scrollToIndex(index, align)Scroll to the specified index position
scrollToOffset(offset, align)Scroll to the specified offset

Usage

import { Component, ViewChild } from '@angular/core';
import { VirtualListComponent } from 'ngx-virtual-sortable';

@Component({
  selector: 'virutal-list',
  template: `
    <div #scroller>
      <virtual-list
        #virtualList
        ...
      >
        ...
      </virtual-list>
    </div>
    <button (click)="scrollToBottom()">scroll to bottom</button>
  `,
  styles: [],
})
export class ListComponent {
  @ViewChild('virtualList') virtualList: VirtualListComponent;

  scrollToBottom() {
    this.virtualList.scrollToBottom();
  }
}

Keywords

ngx

FAQs

Package last updated on 06 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts