diff --git a/.travis.yml b/.travis.yml index f8cde47..b1639ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: -- 5.7.0 +- 6.9.1 env: - CXX=g++-4.8 addons: @@ -12,7 +12,7 @@ addons: before_install: - npm install -g protractor install: -- npm install -g npm@2 +- npm install -g npm@^3 - npm install -g grunt-cli - npm install -g bower - bower install diff --git a/package.json b/package.json index b203ab8..9733c61 100644 --- a/package.json +++ b/package.json @@ -33,19 +33,19 @@ "connect": "^3.4.1", "coveralls": "^2.11.8", "doctoc": "^1.0.0", - "grunt": "^0.4.5", + "grunt": "^1.0.1", "grunt-cli": "^1.2.0", - "grunt-contrib-connect": "^0.11.2", - "grunt-contrib-copy": "^0.8.2", - "grunt-contrib-cssmin": "^0.14.0", + "grunt-contrib-connect": "^1.0.2", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-cssmin": "^2.0.0", "grunt-contrib-jshint": "^1.0.0", - "grunt-contrib-uglify": "^0.11.1", - "grunt-contrib-watch": "^0.6.1", + "grunt-contrib-uglify": "^2.1.0", + "grunt-contrib-watch": "^1.0.0", "grunt-doctoc": "^0.1.1", - "grunt-jscs": "^2.8.0", - "grunt-protractor-runner": "^3.2.0", + "grunt-jscs": "^3.0.1", + "grunt-protractor-runner": "^4.0.0", "grunt-protractor-webdriver": "^0.2.5", - "grunt-sass": "^1.1.0", + "grunt-sass": "^2.0.0", "jasmine-core": "^2.4.1", "karma": "^1.1.2", "karma-coverage": "^1.1.1", diff --git a/src/gridstack.js b/src/gridstack.js index 39d250a..34108cd 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -169,6 +169,7 @@ this._addedNodes = []; this._removedNodes = []; + this._batchQueue = []; }; GridStackEngine.prototype.batchUpdate = function() { @@ -176,9 +177,17 @@ this.float = true; }; - GridStackEngine.prototype.commit = function() { + GridStackEngine.prototype.commit = function(grid) { if (this._updateCounter !== 0) { this._updateCounter = 0; + _.each(this._batchQueue, function(el) { + grid.container.append(el); + grid._prepareElement(el, true); + grid._triggerAddEvent(); + grid._updateContainerHeight(); + grid._triggerChangeEvent(true); + }); + this._batchQueue = []; this.float = this._float; this._packNodes(); this._notify(); @@ -1264,11 +1273,16 @@ if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); } if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); } if (typeof id != 'undefined') { el.attr('data-gs-id', id); } - this.container.append(el); - this._prepareElement(el, true); - this._triggerAddEvent(); - this._updateContainerHeight(); - this._triggerChangeEvent(true); + + if (this.grid._updateCounter) { + this.grid._batchQueue.push(el); + } else { + this.container.append(el); + this._prepareElement(el, true); + this._triggerAddEvent(); + this._updateContainerHeight(); + this._triggerChangeEvent(true); + } return el; }; @@ -1592,7 +1606,7 @@ }; GridStack.prototype.commit = function() { - this.grid.commit(); + this.grid.commit(this); this._updateContainerHeight(); };