Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(infiniteGrid): fix return value of getBottomElement #470

Merged
merged 2 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/infiniteGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ eg.module("infiniteGrid", ["jQuery", eg, window, document], function($, ns, glob
* @ko 레이아웃의 맨 위에 있는 카드 엘리먼트를 반환한다.
* @method eg.InfiniteGrid#getTopElement
*
* @return {HTMLElement} Card element at the top of a layout <ko>레이아웃의 맨 위에 있는 카드 엘리먼트</ko>
* @return {HTMLElement} Card element at the top of a layout. (if the position of card elements are same, it returns the first left element) <ko>레이아웃의 맨 위에 있는 카드 엘리먼트 (카드의 위치가 같은 경우, 왼쪽 엘리먼트가 반환된다)</ko>
*/
getTopElement: function() {
var item = this._getTopItem();
Expand Down Expand Up @@ -425,15 +425,15 @@ eg.module("infiniteGrid", ["jQuery", eg, window, document], function($, ns, glob
* @ko 레이아웃의 맨 아래에 있는 카드 엘리먼트를 반환한다.
* @method eg.InfiniteGrid#getBottomElement
*
* @return {HTMLElement} Card element at the bottom of a layout <ko>레이아웃의 맨 아래에 있는 카드 엘리먼트</ko>
* @return {HTMLElement} Card element at the bottom of a layout (if the position of card elements are same, it returns the first right element)<ko>레이아웃의 맨 아래에 있는 카드 엘리먼트 (카드의 위치가 같은 경우, 오른쪽 엘리먼트가 반환된다)</ko>
*/
getBottomElement: function() {
var item = null;
var max = -Infinity;
var pos;
$.each(this._getColItems(false), function(i, v) {
pos = v ? v.position.y + v.size.height : 0;
if (pos > max) {
if (pos >= max) {
max = pos;
item = v;
}
Expand Down
15 changes: 15 additions & 0 deletions test/unit/js/infiniteGrid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,21 @@ QUnit.test("Check append/prepend methods return", function (assert) {
assert.equal(appendCount, 200);
});

QUnit.test("check getBottomElement method (same position)", function(assert) {
var done = assert.async();
var self = this;

// Given
this.inst = new eg.InfiniteGrid("#grid", {
"count" : 18
}).on("layoutComplete", function(e) {
assert.equal(self.inst.getBottomElement().style.left, "500px");
assert.equal(self.inst.getTopElement().style.left, "0px");
done();
});
});


var complicatedHTML = "<div class='item'><div class='thumbnail'><img class='img-rounded' src='#' /><div class='caption'><p><a href='http://www.naver.com'></a></p></div></div></div>";

QUnit.module("infiniteGrid data type Test", {
Expand Down