|
975 | 975 | }; |
976 | 976 |
|
977 | 977 | GridStack.prototype._prepareElementsByNode = function(el, node) { |
| 978 | + if (typeof $.ui === 'undefined') { |
| 979 | + return; |
| 980 | + } |
978 | 981 | var self = this; |
979 | 982 |
|
980 | 983 | var cellWidth; |
|
1040 | 1043 | var o = $(this); |
1041 | 1044 | self.grid.cleanNodes(); |
1042 | 1045 | self.grid.beginUpdate(node); |
1043 | | - cellWidth = Math.ceil(o.outerWidth() / o.attr('data-gs-width')); |
| 1046 | + cellWidth = self.cellWidth(); |
1044 | 1047 | var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); |
1045 | 1048 | cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); |
1046 | 1049 | self.placeholder |
|
1160 | 1163 | }, triggerAddEvent); |
1161 | 1164 | el.data('_gridstack_node', node); |
1162 | 1165 |
|
1163 | | - if (!this.opts.staticGrid) { |
1164 | | - this._prepareElementsByNode(el, node); |
1165 | | - } |
| 1166 | + this._prepareElementsByNode(el, node); |
1166 | 1167 | }; |
1167 | 1168 |
|
1168 | 1169 | GridStack.prototype.setAnimation = function(enable) { |
|
1258 | 1259 | el.each(function(index, el) { |
1259 | 1260 | el = $(el); |
1260 | 1261 | var node = el.data('_gridstack_node'); |
1261 | | - if (self.opts.staticGrid || typeof node == 'undefined' || node === null) { |
| 1262 | + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { |
1262 | 1263 | return; |
1263 | 1264 | } |
1264 | 1265 |
|
|
1278 | 1279 | el.each(function(index, el) { |
1279 | 1280 | el = $(el); |
1280 | 1281 | var node = el.data('_gridstack_node'); |
1281 | | - if (self.opts.staticGrid || typeof node == 'undefined' || node === null) { |
| 1282 | + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { |
1282 | 1283 | return; |
1283 | 1284 | } |
1284 | 1285 |
|
|
1493 | 1494 | }; |
1494 | 1495 |
|
1495 | 1496 | GridStack.prototype.cellWidth = function() { |
1496 | | - var o = this.container.children('.' + this.opts.itemClass).first(); |
1497 | | - return Math.ceil(o.outerWidth() / parseInt(o.attr('data-gs-width'), 10)); |
| 1497 | + return Math.round(this.container.outerWidth() / this.opts.width); |
1498 | 1498 | }; |
1499 | 1499 |
|
1500 | 1500 | GridStack.prototype.getCellFromPixel = function(position, useOffset) { |
|
0 commit comments