Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drag-enabled

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drag-enabled

Have you looked at all the other Angular drag and drop libraries and noted they are not generic enough to fit within your design?

  • 0.1.1
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to Drag Enabled!

Have you looked at all the other Angular drag and drop libraries and noted they are not generic enough to fit within your design?

This library provides Angular 4 directives that enables you to have any html tag drag drop enabled within your component control just by adding DragDropModule into your AppModule.

You will be able to pass a medium object to the directives. The meduim will supposedly have or know of certain things that can help your code make a decision on allowing a drag or a drop to take place. It could be a reference to a node or a structure in your code. At the start, a "dragEnabled" requst with a DragEvent will be sent to your component. if returned true, dragging begins. At the end of drag operation, an event with the source medium, source HTMLElement, destination medium, and destination HTMLElement will be sent to your component to perform any action necessary.

Version 0.1.1

Turned out that this library can become a lot more usefull if i pass the event location as well. So here it is... Made the new attributes optional to make it compatible for those who are using previous version if they get an accidental upgrade through npm install... cursorX, cursorY names are chosen to avoid confusion over browser compatibility between Mozilla, and other browsers..

export interface DragEvent {
    medium: any,
    node: HTMLElement,
    cursorX?: number,
    cursorY?: number,
    offset?: {
        x: number, 
        y: number
    }
}

export interface DropEvent {
    source: {
		medium: any,
		node: HTMLElement,
		cursorX?: number,
		cursorY?: number,
		offset?: {
			x: number, 
			y: number
		}
    },
    destination: {
        medium: any,
        node: HTMLElement,
		cursorX?: number,
		cursorY?: number
    }
}

Version 0.0.1

MODULE: 
		DragDropModule

DEPENDENCIES: 
		basic Angular core libraries

Interfaces

export interface DragEvent {
    medium: any,
    node: HTMLElement
}

export interface DropEvent {
    source: {
        medium: any,
        node: HTMLElement
    },
    destination: {
        medium: any,
        node: HTMLElement
    }
}

The following are available functionalities presented in this version:

Sample code

<th scope="col"
	[medium]="headerInfo"
	[dragEnabled]="isDragEnabled.bind(this)"
	[dropEnabled]="dropEnabled.bind(this)"
	(onDragStart)="onDragStart($event)"
	(onDrag)="onDrag($event)"
	(onDragEnd)="onDragEnd($event)"
	(onDrop)="onDrop($event)">header text</th>

	.............

  	isDragEnabled(event: DragEvent) {
		return event.medium.dragable;
	}
	onDragStart(event: DragEvent){
	}
	onDrag(event: DragEvent){
	}
	onDragEnd(event: DragEvent){
	}
	
	dropEnabled(event: DropEvent) {
		return event.destination.medium.dragable;
	}
	onDrop(event: DropEvent){
	//	swapColumns(source.medium, source.node, destination.medium, destination.node);
	}

	.............

	table {
		th {
			&.drag-over {
				background-color: #9b9b9b;

				.title, .icon {
				color: #eee;
			}
		}
	}
	

Source code

FAQs

Package last updated on 20 Mar 2018

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc