Skip to content

Commit

Permalink
fix(infiniteGrid): fire append event after resize
Browse files Browse the repository at this point in the history
  • Loading branch information
sculove committed Mar 9, 2017
1 parent e111dec commit 03a0e57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/infiniteGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ eg.module("infiniteGrid", ["jQuery", eg, window, document], function($, ns, glob
self._refreshViewport();
(self.$el.innerWidth() !== self._containerWidth) && self.layout(true);
self._resizeTimeout = null;
self._prevScrollTop = -1;
}, 100);
},
_refreshViewport: function() {
Expand Down
19 changes: 18 additions & 1 deletion test/unit/js/infiniteGrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,8 @@ QUnit.test("if width is not changed, layout should be not called on resize event
$global.on("resize", function(e) {
resizeCount++;
});

$global.scrollTop(10000);

// When
$global.trigger("resize");

Expand Down Expand Up @@ -921,6 +922,22 @@ QUnit.test("check _refreshViewport method", function(assert) {
});


QUnit.test("check _prevScrollTop after resize event.", function(assert) {
// Given
var done = assert.async();
var inst = this.inst = new eg.InfiniteGrid("#grid");
assert.equal(inst._prevScrollTop, 0);

// When
inst._onResize();

// Then
setTimeout(function() {
assert.equal(inst._prevScrollTop, -1);
done();
},200);
});

QUnit.module("infiniteGrid layout(false) Test", {
beforeEach : function() {
this.inst = new eg.InfiniteGrid("#nochildren_grid", {
Expand Down

0 comments on commit 03a0e57

Please sign in to comment.