ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.03k stars 1.2k forks source link

Drag is only intermittently working #216

Closed duncanol closed 11 years ago

duncanol commented 11 years ago

Hi there,

About 9 times out of 10 when I refresh the page with the gridster instance on and an item is dragged it throws several "Uncaught TypeError: Cannot read property 'size_y' of undefined" and "Uncaught TypeError: Cannot call method 'get_closest_colliders' of undefined" errors.

There seems to be some race condition at work?

I saw a possible connected issue, but it appears to have been fixed for a long time - https://github.com/ducksboard/gridster.js/issues/17.

We're using version 0.1.0 from 2013-06-14. Other javascript libraries we're using: jquery-migrate-1.2.1 jquery-ui-1.10.1 bootstrap jquery.slimscroll jquery.blockui jquery.cookie jquery.uniform

I'm using the latest stable Chrome and Firefox for Ubuntu 13.04.

Thanks in advance for any help you could provide me, Duncan

duncanol commented 11 years ago

Our mistake. There was indeed a race condition, but it was in our javascript that was allocation the "data" attributes to the gridster li elements too slowly, and gridster is initialized in error before the attributes are there on the li's. This caused the "grid" object to be initialized with NaNs for its dimension attributes.

There wasn't any error in creating the gridster however - perhaps there should be and it'd be easier to diagnose init issues?

Thanks, Duncan