Skip to content

Commit

Permalink
fix(infiniteGrid): fix layout issue. (#311)
Browse files Browse the repository at this point in the history
layout is bronken on iOS

ref #427, #y-300, #y301
  • Loading branch information
sculove authored and GitHub Enterprise committed Dec 8, 2016
1 parent 7ad1518 commit 4af89e0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/infiniteGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ eg.module("infiniteGrid", ["jQuery", eg, window, document], function($, ns, glob
}, 100);
},
_refreshViewport: function() {
this._clientHeight = this.$view.height();
var el = this.$view.get(0);
if (el) {
this._clientHeight = $.isWindow(el) ? el.innerHeight : el.clientHeight;
}
},
/**
* Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.
Expand Down
35 changes: 35 additions & 0 deletions test/unit/js/infiniteGrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,4 +818,39 @@ QUnit.test("if width is not changed, layout should be not called on resize event
assert.equal(inst.$el.innerWidth(), inst._containerWidth, "width is not changed");
done();
},100);
});



QUnit.module("infiniteGrid private method Test", {
beforeEach : function() {
this.fakeWnd = {
navigator : {
userAgent: "iPad"
},
innerHeight: 100,
clientHeight: 100
};
eg.invoke("infiniteGrid", [ null, null, this.fakeWnd, null, null]);
},
afterEach : function() {
if(this.inst) {
this.inst.destroy();
this.inst = null;
}
}
});


QUnit.test("check _refreshViewport method", function(assert) {
// Given
var inst = new eg.InfiniteGrid("#grid");
// When
assert.equal(inst._clientHeight, 100, "height is not changed");

this.fakeWnd.innerHeight = this.fakeWnd.clientHeight = 200;
inst._refreshViewport();

// Then
assert.equal(inst._clientHeight, 200, "height is changed");
});

0 comments on commit 4af89e0

Please sign in to comment.