Socket
Socket
Sign inDemoInstall

ngx-mega-simple-drag-drop-list

Package Overview
Dependencies
5
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-mega-simple-drag-drop-list

Angular 2/3/4/5/6/7 Drag Drop Simple Reordable List Items


Version published
Weekly downloads
205
increased by23.49%
Maintainers
1
Install size
138 kB
Created
Weekly downloads
 

Readme

Source

NPM

NgxMegaSimpleDragDropList

Angular 2/3/4/5/6/7 Drag Drop Simple Reordable List Items

Screenshot

Screenshot

*had to photoshop the little dragging cursor. Guess it will look different in different OS's and browsers

Demo

https://ives.me/NgxMegaSimpleDragDropListDemoWithNpmPackage/

Install

npm i ngx-mega-simple-drag-drop-list

app.module.ts

import { NgxMegaSimpleDragDropListModule } from 'ngx-mega-simple-drag-drop-list';

@NgModule({
	imports: [
		NgxMegaSimpleDragDropListModule
	],
})

app.component.ts


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

@Component({
	selector: 'app-root',
	templateUrl: './app.component.html',
	styleUrls: ['./app.component.css']
})
export class AppComponent {
	items = [1, 2, 3, 4, 5]; 

	constructor() { }

	ngOnInit() {}

	onDropped(newItems) {
		this.items = newItems;
	}
}

app.component.html

<div class="card" *ngFor="let item of items;let index = index;" megaSimpleDndList [items]="items" [index]="index" (dropped)="onDropped($event)">
	<div class="card-content">
		{{item}}
	</div>
</div>

app.component.css

.card {
	cursor: move;
	float: left;
	position: relative;
	margin: .5rem 1rem 1rem 0;
	background-color: #fff;
	transition: box-shadow opacity .25s;
	border-radius: 2px;
	box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.2);
}

.card .card-content{
	pointer-events: none; /*make sure you add this to all card children. This ensures only the card is dragged*/
	padding: 40px;
	border-radius: 0 0 2px 2px;
	font-size: 30px;	
	text-align: center;
}

.hover {
	box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
}

.draggin {
	opacity: 0.4;
}

API

Inputs

InputTypeDefaultRequiredDescription
itemsarrayany[]yesArray to reorder
indexnumbernullyesIndex of the current element
hoverStylestringhovernoCss class name when hovering
dragStylestringdragginnoCss class name when dragging the element
isSwapbooleanfalsenoControls if you want to swap items in the array or reorder the whole array

Outputs

OutputTypeDescription
(dropped)arrayReturns the array

Keywords

FAQs

Last updated on 20 Feb 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc