Skip to content

Commit

Permalink
Fixed #6100
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici authored and Çağatay Çivici committed Jul 26, 2018
1 parent da51d03 commit 4ddd39b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/app/components/dragdrop/dragdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {DomHandler} from '../dom/domhandler';

@Directive({
selector: '[pDraggable]',
host: {
'[draggable]': 'true'
},
providers: [DomHandler]
})
export class Draggable implements AfterViewInit, OnDestroy {

@Input('pDraggable') scope: string;

@Input() pDraggableDisabled: boolean;

@Input() dragEffect: string;

Expand All @@ -34,7 +33,10 @@ export class Draggable implements AfterViewInit, OnDestroy {
constructor(public el: ElementRef, public domHandler: DomHandler, public zone: NgZone) {}

ngAfterViewInit() {
this.bindMouseListeners();
if (!this.pDraggableDisabled) {
this.el.nativeElement.draggable = true;
this.bindMouseListeners();
}
}

bindDragListener() {
Expand Down Expand Up @@ -133,6 +135,8 @@ export class Draggable implements AfterViewInit, OnDestroy {
export class Droppable implements AfterViewInit, OnDestroy {

@Input('pDroppable') scope: string|string[];

@Input() pDroppableDisabled: boolean;

@Input() dropEffect: string;

Expand All @@ -147,7 +151,9 @@ export class Droppable implements AfterViewInit, OnDestroy {
dragOverListener: any;

ngAfterViewInit() {
this.bindDragOverListener();
if (!this.pDroppableDisabled) {
this.bindDragOverListener();
}
}

bindDragOverListener() {
Expand Down
13 changes: 12 additions & 1 deletion src/app/showcase/components/dragdrop/dragdropdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ <h3>Drag Handle</h3>
</code>
</pre>


<h3>Draggable</h3>
<h4>Attributes</h4>
<div class="doc-tablewrapper">
Expand All @@ -106,6 +105,12 @@ <h4>Attributes</h4>
<td>null</td>
<td>Selector to define the drag handle, by default anywhere on the target element is a drag handle to start dragging.</td>
</tr>
<tr>
<td>pDraggableDisabled</td>
<td>boolean</td>
<td>false</td>
<td>Whether the element is draggable, useful for conditional cases.</td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -165,6 +170,12 @@ <h4>Attributes</h4>
<td>null</td>
<td>Defines the cursor style on drag over, valid values are copy, relocate, link and move.</td>
</tr>
<tr>
<td>pDroppableDisabled</td>
<td>boolean</td>
<td>false</td>
<td>Whether the element is droppable, useful for conditional cases.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 4ddd39b

Please sign in to comment.