Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
1. add new README
2. fix ngDraggable setting issue
  • Loading branch information
Xie, Ziyu committed May 3, 2017
1 parent 9df93b8 commit fd277a6
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 6 deletions.
75 changes: 73 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# angular2-draggable
Angular directive (for version >= 2.x ) that makes the DOM element draggable
# angular2-draggable [![npm version](https://badge.fury.io/js/angular2-draggable.svg)](http://badge.fury.io/js/angular2-draggable) [![npm downloads](https://img.shields.io/npm/dm/angular2-draggable.svg)](https://npmjs.org/angular2-draggable)
Angular directive (for version >= 2.x ) that makes the DOM element draggable. Please refer to the [demo](https://xieziyu.github.io/#/angular2-draggable/demo) page.

## Table of contents
1. [Getting Started](#getting-started)
3. [Installation](#installation)
4. [Usage](#usage)
5. [API](#api)
6. [Events](#events)

# Getting Started
angular2-draggable is an angular (ver >= 2.x) directive that makes the DOM element draggable. (Note that: It's different from drag-and-drop)

# Installation
```
npm install angular2-draggable --save
```

# Usage
Please refer to the [demo](https://xieziyu.github.io/#/angular2-draggable/demo) page.

1. Firstly, import `AngularDraggableModule` in your app module (or any other proper angular module):
```typescript
import { AngularDraggableModule } from 'angular2-draggable';

@NgModule({
imports: [
...,
AngularDraggableModule
],
...
})
export class AppModule { }
```

2. Then: use `ngDraggable` directive to make the DOM element draggable.
+ Simple example:

+ html:
```html
<div ngDraggable>Drag me!</div>
```

+ Use `[handle]` to move parent element:

+ html:
```html
<div ngDraggable [handle]="DemoHandle" class="card">
<div #DemoHandle class="card-header">I'm handle. Drag me!</div>
<div class="card-block">You can't drag this block now!</div>
</div>
```

# API

## Directive:
`ngDraggable` directive support following input porperties:
+ `ngDraggable`: boolean. You can toggle the draggable capability by setting `true`/`false` to `ngDraggable`

+ `handle`: HTMLElement. Use template variable to refer to the handle element. Then only the handle element is draggable.

## CSS:
When `ngDraggable` is enabled on some element, `ng-draggable` class is automatically assigned to it. You can use it to customize the pointer style. For example:

```css
.ng-draggable {
cursor: move;
}
```

# Events

To be supported soon.
21 changes: 21 additions & 0 deletions dist/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Xie, Ziyu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
73 changes: 73 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# angular2-draggable [![npm version](https://badge.fury.io/js/angular2-draggable.svg)](http://badge.fury.io/js/angular2-draggable) [![npm downloads](https://img.shields.io/npm/dm/angular2-draggable.svg)](https://npmjs.org/angular2-draggable)
Angular directive (for version >= 2.x ) that makes the DOM element draggable. Please refer to the [demo](https://xieziyu.github.io/#/angular2-draggable/demo) page.

## Table of contents
1. [Getting Started](#getting-started)
3. [Installation](#installation)
4. [Usage](#usage)
5. [API](#api)
6. [Events](#events)

# Getting Started
angular2-draggable is an angular (ver >= 2.x) directive that makes the DOM element draggable. (Note that: It's different from drag-and-drop)

# Installation
```
npm install angular2-draggable --save
```

# Usage
Please refer to the [demo](https://xieziyu.github.io/#/angular2-draggable/demo) page.

1. Firstly, import `AngularDraggableModule` in your app module (or any other proper angular module):
```typescript
import { AngularDraggableModule } from 'angular2-draggable';

@NgModule({
imports: [
...,
AngularDraggableModule
],
...
})
export class AppModule { }
```

2. Then: use `ngDraggable` directive to make the DOM element draggable.
+ Simple example:

+ html:
```html
<div ngDraggable>Drag me!</div>
```

+ Use `[handle]` to move parent element:

+ html:
```html
<div ngDraggable [handle]="DemoHandle" class="card">
<div #DemoHandle class="card-header">I'm handle. Drag me!</div>
<div class="card-block">You can't drag this block now!</div>
</div>
```

# API

## Directive:
`ngDraggable` directive support following input porperties:
+ `ngDraggable`: boolean. You can toggle the draggable capability by setting `true`/`false` to `ngDraggable`

+ `handle`: HTMLElement. Use template variable to refer to the handle element. Then only the handle element is draggable.

## CSS:
When `ngDraggable` is enabled on some element, `ng-draggable` class is automatically assigned to it. You can use it to customize the pointer style. For example:

```css
.ng-draggable {
cursor: move;
}
```

# Events

To be supported soon.
2 changes: 1 addition & 1 deletion dist/directive/angular-draggable.directive.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/directive/angular-draggable.directive.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/directive/angular-draggable.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Position {
@Directive({
selector: '[ngDraggable]'
})
export class AngularDraggableDirective implements OnInit{
export class AngularDraggableDirective implements OnInit {
private allowDrag: boolean = true;
private moving: boolean = false;
private orignal: Position = null;
Expand All @@ -16,7 +16,7 @@ export class AngularDraggableDirective implements OnInit{

@Input()
set ngDraggable(setting: any) {
if (setting != undefined && setting != null && setting != '') {
if (setting !== undefined && setting !== null && setting !== '') {
this.allowDrag = !!setting;

let element = this.handle ? this.handle : this.el.nativeElement;
Expand Down

0 comments on commit fd277a6

Please sign in to comment.