ManifestWebDesign / angular-gridster

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

Resize callback gets the map object for the widget #213

Open mconner opened 9 years ago

mconner commented 9 years ago

When using a custom item map, the "widget" passed to the resize function is the map, rather than the original source object. For example, using the demo script.js, and adding:

resize: function(event, $element, widget) {
    console.log("in resizeable.resize", widget);
}

to the resizable config. When doing a resize, the output is: in resizeable.resize Object {sizeX: "item.size.x", sizeY: "item.size.y", row: "item.position[0]", col: "item.position[1]"}

I would think it should be the actual object, as defined in $scope.customItems[n]. For example:

{
    size: {x: 2, y: 1 },
    position: [0, 0]
}

I think this applies to the other callbacks, as well.

kumaravnish commented 9 years ago

+1

cmjacques commented 9 years ago

+1

I've modified the gridster.resizable.stop and gridster.draggable.stop callbacks to return size and position objects ({ sizeX: item.sizeX, sizeY: item.sizeY } and { row: row, col: col }).

I've also modified the gridster.resizable.start and gridster.draggable.start callbacks to return size and position so that I can compare the original size/position values with the final values (from stop).

jozsi commented 9 years ago

+1

k1ng440 commented 9 years ago

+1

Moulde commented 8 years ago

Like the above, when using a custom map object, then the map object is returned as "widget" in resize event. And when using a custom widget object without the necessary sizeX PositionX etc, and then using the attributes to map to the actual properties like so.

<div gridster>
    <ul>
        <li gridster-item row="item.position[0]" col="item.position[1]" size-x="item.size.x" size-y="item.size.y" ng-repeat="item in customItems"></li>
    </ul>
</div>

Then the widget object returned as "widget" is the above element.

And when binding the correct widget object, that has the right sizeX positionY properties, then the bound object is returned in the resize function.

I would expect the behavior of the resize function to be the same, no matter if using a widget object, a custom map or mapping using the attributes. It should always be returning the "item" object.