Famo.us/Angular get current position after drag&drop

201 Views Asked by At

I've managed to create a draggable surface using fa-draggable,however I cannot figure out how to get the current position of the surface after the dragging has finished. My HTML :

`<fa-modifier ng-repeat="object in objects" fa-size="[object.size.width, object.size.height]" fa-translate="[object.translate.x, object.translate.y]">
    <fa-draggable fa-pipe-from="object.handler">
        <fa-surface ng-class="{btn: isButton(object)}" fa-background-color="object.backgroundColor" fa-pipe-to="object.handler" ng-click="openAttrs(objects.indexOf(object))">
            {{object.text}}
        </fa-surface>
    </fa-draggable>
</fa-modifier>`

Also since we are here if anyone can recommend a way to resize a surface interactively that would be appreciated.

2

There are 2 best solutions below

0
On

I am not familiar with Famous-Angular but answered this when addressing the question using standard Famo.us to manage a draggable surface See this Stackoverflow Answer.

I am sure it should apply for Famous-Angular also.

0
On

u have to fa-pipe-to in drag too so all events that go to fa-draggable will go back to handler just change

<fa-draggable fa-pipe-from="object.handler">

to

<fa-draggable fa-pipe-from="object.handler" fa-pipe-to="object.handler">

and in the handler do js:

object.handler.on('end', function (d) {
   console.log(d.posiotion);
});