1.0.0 • Published 6 years ago

ngx-hm-sortable v1.0.0

Weekly downloads
16
License
-
Repository
-
Last release
6 years ago

ngx-hm-sortable GitHub

Upgrade to Angular 6+ and Rxjs6+

Angular sortable with hammerjs, support SSR(server side rendering).

Demo

npm.io

Install

  1. install
npm install ngx-hm-sortable

Example

  1. Module
import { NgxHmSortableModule } from 'ngx-hm-sortable';

@NgModule({
  declarations: [ ...something... ],
  imports: [ ...something... , NgxHmSortableModule],
  providers: [ ...something... ],
  bootstrap: [ ...something... ]
})
export class YourModule {
  ...something...
}
  1. TS
import { Component } from '@angular/core';

@Component({
  ... something ...
})
export class YourComponent {
  list = [1, 2, 3, 4, 5];
}
  1. HTML
<table>
  <tbody
    [ngx-hm-sortable]="list"
    elms-selector=".item"
    move-selector=".drag"
    selected-class="color-blue"
    moving-class="color-red"
    (sort-complete)="complete($event)">
    <tr>
      <th>sortable</th>
      <th>number</th>
    </tr>
    <tr *ngFor="let item of list; let i = index;" [attr.index]="i" class="item">
      <td>
        <span class="drag">dragMe!</span>
      </td>
      <td>{{item}}</td>
    </tr>
  </tbody>
</table>

Attribute

Attributenecessary(default)typepositiondescription
ngx-hm-sortableyesArraycontaineradd sortable by item array.
elms-selectoryesStringcontainerthe sortable items selector
move-selectorno (elms-selector)Stringcontainerthe move Anchor
sortable-idno / (random)Stringcontainerthe container unique id
sortable-enableno / (true)Booleancontainersortable enable state, default
moving-classnostringcontaineradd class with selected new element
selected-classnostringcontaineradd class with selected origin element.
(sort-complete)no(Array)=>voidcontainerwhen sortable complete, emit this new array
attr.indexyesNumber(Integer)itemthe index of array
1.0.0

6 years ago

0.0.1

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago