s-yadav / angulargrid

Pinterest like responsive masonry grid system for angular
MIT License
277 stars 105 forks source link

TypeError: Cannot read property 'offsetWidth' of undefined at ... when using cssGrid #82

Closed jice-lavocat closed 8 years ago

jice-lavocat commented 8 years ago

I'm using the following code :

<div class="row dynamic-grid gridMessages"  angular-grid="repost.messages" ag-options="{cssGrid : true}" ag-id="messagesGrid">
      <div ng-repeat="message in repost.messages" class="grid col-lg-4 col-sm-6">
            <div message-View></div>
      </div>
</div>

I works, but I get the following log trace :

angular.js:12793 TypeError: Cannot read property 'offsetWidth' of undefined
    at getColWidth (http://localhost:9000/bower_components/angulargrid/angulargrid.js:336:37)
    at reflowGrids (http://localhost:9000/bower_components/angulargrid/angulargrid.js:398:29)
    at http://localhost:9000/bower_components/angulargrid/angulargrid.js:607:21
    at http://localhost:9000/bower_components/angular/angular.js:18227:31
    at completeOutstandingRequest (http://localhost:9000/bower_components/angular/angular.js:5677:10)
    at http://localhost:9000/bower_components/angular/angular.js:5954:7
    at ZoneDelegate.invokeTask (http://localhost:9000/bower_components/opbeat-angular/opbeat-angular.js:2095:38)
    at Object.onInvokeTask (http://localhost:9000/bower_components/opbeat-angular/opbeat-angular.js:5947:37)
    at ZoneDelegate.invokeTask (http://localhost:9000/bower_components/opbeat-angular/opbeat-angular.js:2094:43)
    at Zone.runTask (http://localhost:9000/bower_components/opbeat-angular/opbeat-angular.js:1995:48) undefined
Luddinus commented 8 years ago

+1

nkovacic commented 8 years ago

+1 This happens when ng-repeat yields no elements and angularGrid can't calculate the width of the first element. I think there should be a watcher for ng-repeat so that the first time it yields some elements it calculates the size.

nkovacic commented 8 years ago

A quick hack fix for this is an empty placeholder with the responsive css class: `

<div class="grid col-lg-4 col-sm-6"></div>

`

jice-lavocat commented 8 years ago

@s-yadav Hi thanks for the fix/commit. I've seen you updated the version number too, great. Unfortunately, I am not able to get it from bower. Do you need to update it or have I missed something ?

nkovacic commented 8 years ago

An official release is not yet published.