xieziyu / angular2-draggable

Angular directive (for version >= 2.x ) that makes the DOM element draggable and resizable
https://xieziyu.github.io/angular2-draggable/
294 stars 103 forks source link

Using drag and resize but struggling to save position and size. #185

Open scottheappey opened 5 years ago

scottheappey commented 5 years ago

Geting x=Nan & y=Nan

How do I write this so that if undefined don't use: [position]='{x: xitem.x, y:xitem.y}'

scottheappey commented 5 years ago

I managed to save the position. But I'm sure there is a better way to write this:

<div *ngIf="xitem.x" ngDraggable (endOffset)="onMoveEnd(xitem, $event)" [position]='{x: xitem.x, y:xitem.y}' ngResizable [rzHandles]="'n,e,s,w,se,sw,ne,nw'" (rzStop)="onResizeStop(xitem, $event)" id="pill" class="pill"> ....

and

<div *ngIf="!xitem.x" ngDraggable (endOffset)="onMoveEnd(xitem, $event)" ngResizable [rzHandles]="'n,e,s,w,se,sw,ne,nw'" (rzStop)="onResizeStop(xitem, $event)" id="pill" class="pill"> ....

Now I need to save the size and position after resizing ...