Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return dragged fa-surface back to its origin using famo/angular?

Im using fa-draggable directive which works:

<fa-modifier fa-size="[90, 90]">
             <fa-draggable fa-pipe-from="item.handler"
                           fa-options="draggableOptions"
                           fa-pipe-to="item.handler">
                           <fa-surface fa-background-color="'#268bd2'"
                                       fa-pipe-to="item.handler">
                                        A
                           </fa-surface>
             </fa-draggable>
</fa-modifier>

And inside my controller I set:

$scope.draggableOptions = {
        xRange: [-4, 4],
        yRange: [-4, 4]
    };
$scope.item.handler = new EventHandler();
$scope.item.handler.on('end', function (e) {
                //return somehow to default position
            });

How can I assure that after drag event is done, the draggable surface is returned to default position?

I found this question Drag a Famous surface and have it transition back to origin on mouseup? but I dont know how can I use "setPosition" function in my case?

like image 600
Matúš Bartko Avatar asked Dec 15 '25 08:12

Matúš Bartko


1 Answers

You can setPosition

$famous.find('fa-draggable')[0].modifier.setPosition([4,4])

Demo Plunker: http://plnkr.co/edit/ZwLFXsjoxHyXqPpUgxJh?p=preview

like image 55
Vidyadhar Avatar answered Dec 16 '25 23:12

Vidyadhar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!