Dan Moldovan
Dan Moldovan

Reputation: 3591

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

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.

Upvotes: 0

Views: 186

Answers (2)

Karol Arakelian
Karol Arakelian

Reputation: 11

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);
});

Upvotes: 1

talves
talves

Reputation: 14353

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.

Upvotes: 0

Related Questions