Giter VIP home page Giter VIP logo

Comments (3)

danomatic avatar danomatic commented on May 28, 2024

Great question. The typical Angular way would be to do a $scope.$watch on your item or items in the scope. Example:

// two objects, converted to gridster items in the view via ng-repeat
$scope.items = [{},{}];

$scope.$watch('items', function(items){
   // one of the items changed
}, true);

or

$scope.watch('items[0]', function(){
   // item0 changed
}, true);

or

$scope.watch('items[0].sizeX', function(){
   // item0 sizeX changed
}, true);

The third argument, true, is to make the watch based on the value of the object, rather than just matching the reference to the object.

The biggest challenge I've seen is knowing how to know when any if the items has changed while avoiding excessive calls to watch functions. It would be nice to have an event emitted when something changes, but only after all items in the grid have settled and stopped moving. If anyone else has ideas, they are welcome.

from angular-gridster.

brayniverse avatar brayniverse commented on May 28, 2024

Brilliant, mind putting this in the docs for others? If you don't have time I can make a pull request.

from angular-gridster.

danomatic avatar danomatic commented on May 28, 2024

I copied and pasted directly from this and committed. Feel free to enhance or suggest improvements. Thanks!

from angular-gridster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.