Skip to content

Commit

Permalink
fix(infiniteGrid): fix return value of getBottomElement (#470)
Browse files Browse the repository at this point in the history
* fix(infiniteGrid): fix return value of getBottomElement

close #467

* skip: apply review
  • Loading branch information
sculove authored Mar 7, 2017
1 parent 63e19d2 commit 64bdb65
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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

0 comments on commit 64bdb65

Please sign in to comment.