ManifestWebDesign / angular-gridster

An implementation of gridster-like widgets for Angular JS
http://manifestwebdesign.github.io/angular-gridster/
MIT License
966 stars 395 forks source link

Watching for gridster item events #434

Open gverma14 opened 7 years ago

gverma14 commented 7 years ago

I am currently using gridster items as wrappers for my html content and one thing that I could not get around was ensuring that the final size of my content matches the size of my widget after the transition is complete. I tried using the resize stop function but it gives me the size of the widget at the point right before the transition. I had to change the event gridster-item-transition-end to be a $emit instead of a $broadcast in order for my controller to recognize it. When I ran grunt locally with the tests I got back a failure. I'm not sure if this would be in line with the desired behavior / intended purpose of the event. Is this a valid approach?

mirik123 commented 7 years ago

You can do ti this way:

$scope.addItemListener = function (scope, itm) {
       scope.$on('gridster-item-transition-end', function (event, source) { ... });
}

where scope is from here:

<div ng-repeat="itm in items" gridster-item="itm">
         <div ng-init="addItemListener(this, itm)">
         </div>
</div>