forked from naver/egjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfiniteGrid.js
770 lines (737 loc) · 21.7 KB
/
infiniteGrid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
/**
* Copyright (c) 2015 NAVER Corp.
* egjs projects are licensed under the MIT license
*/
// jscs:disable validateLineBreaks, maximumLineLength
eg.module("infiniteGrid", ["jQuery", eg, window, "Outlayer"], function($, ns, global, Outlayer) {
"use strict";
// jscs:enable validateLineBreaks, maximumLineLength
if (!Outlayer) {
ns.InfiniteGrid = ns.Class({});
return;
}
function clone(target, source, what) {
var s;
$.each(what, function(i, v) {
s = source[v];
if (s != null) {
if ($.isArray(s)) {
target[v] = $.merge([], s);
} else if ($.isPlainObject(s)) {
target[v] = $.extend(true, {}, s);
} else {
target[v] = s;
}
}
});
return target;
}
var InfiniteGridCore = Outlayer.create("InfiniteGrid");
$.extend(InfiniteGridCore.prototype, {
// @override (from layout)
_resetLayout: function() {
if (!this._isLayoutInited) {
this._registGroupKey(this.options.defaultGroupKey, this.items);
}
this.element.style.width = null;
this.getSize(); // create size property
this._measureColumns();
},
// @override
_getContainerSize: function() {
return {
height: Math.max.apply(Math, this._appendCols),
width: this.size.innerWidth
};
},
// @override
_getItemLayoutPosition: function(item) {
if (this._equalItemSize) {
item.size = this._equalItemSize;
} else {
item.getSize();
}
(item.isAppend == null) && (item.isAppend = true);
var y;
var shortColIndex;
var isAppend = item.isAppend;
var cols = isAppend ? this._appendCols : this._prependCols;
y = Math[isAppend ? "min" : "max"].apply(Math, cols);
shortColIndex = $.inArray(y, cols);
cols[shortColIndex] = y + (isAppend ?
item.size.outerHeight : -item.size.outerHeight);
return {
x: this.columnWidth * shortColIndex,
y: isAppend ? y : y - item.size.outerHeight
};
},
resetLayout: function() {
this._resetLayout();
this._isLayoutInited = true;
},
updateCols: function(isAppend) {
var col = isAppend ? this._appendCols : this._prependCols;
var items = this.getColItems(isAppend);
var base = this._isFitted || isAppend ? 0 : this._getMinY(items);
var i = 0;
var len = col.length;
var item;
for (; i < len; i++) {
if (item = items[i]) {
col[i] = item.position.y + (isAppend ? item.size.outerHeight : -base);
} else {
col[i] = 0;
}
}
return base;
},
_getMinY: function(items) {
return Math.min.apply(Math, $.map(items, function(v) {
return v ? v.position.y : 0;
}));
},
_measureColumns: function() {
var containerWidth = this.size.innerWidth;
var columnWidth = this._getColumnWidth();
var cols = containerWidth / columnWidth;
var excess = columnWidth - containerWidth % columnWidth;
// if overshoot is less than a pixel, round up, otherwise floor it
cols = Math.max(Math[ excess && excess < 1 ? "round" : "floor" ](cols), 1);
// reset column Y
this._appendCols = [];
this._prependCols = [];
while (cols--) {
this._appendCols.push(0);
this._prependCols.push(0);
}
},
_getColumnWidth: function() {
var el = this.items[0] && this.items[0].element;
var size;
if (el) {
/* jshint ignore:start */
size = getSize(el);
/* jshint ignore:end */
} else {
size = {
outerWidth: 0,
outerHeight: 0
};
}
this.options.isEqualSize && (this._equalItemSize = size);
this.columnWidth = size.outerWidth || this.size.outerWidth;
return this.columnWidth;
},
_getColIdx: function(item) {
return parseInt(item.position.x / parseInt(this.columnWidth, 10), 10);
},
getColItems: function(isTail) {
var len = this._appendCols.length;
var colItems = new Array(len);
var item;
var idx;
var count = 0;
var i = isTail ? this.items.length - 1 : 0;
while (item = this.items[i]) {
idx = this._getColIdx(item);
if (!colItems[idx]) {
colItems[idx] = item;
if (++count === len) {
return colItems;
}
}
i += isTail ? -1 : 1;
}
return colItems;
},
clone: function(target, source) {
clone(target, source, [
"_isLayoutInited",
"_equalItemSize",
"_appendCols",
"_prependCols",
"columnWidth",
"size",
"options"
]);
target.items = target.items || [];
target.items.length = source.items.length;
$.each(source.items, function(i) {
target.items[i] = clone(target.items[i] || {}, source.items[i],
["position", "size", "isAppend", "groupKey"]);
});
return target;
},
itemize: function(elements, groupKey) {
var items = this._itemize(elements);
this._registGroupKey(groupKey, items);
return items;
},
_registGroupKey: function(groupKey, array) {
if (groupKey != null) {
var i = 0;
var v;
while (v = array[i++]) {
v.groupKey = groupKey;
}
}
},
// @override
destroy: function() {
this.off();
Outlayer.prototype.destroy.apply(this);
}
});
/**
* To build Grid layout UI
* InfiniteGrid is composed using Outlayer and supports recycle-dom.
* DOM elements are fixed even contents are added infinitely.
* @group egjs
* @ko 그리드 레이아웃을 구성하는 UI 컴포넌트. InfiniteGrid는 Outlayer로 구성되어 있다. 하지만, 이 컴포넌트는 recycle-dom을 지원한다.
* 컨텐츠를 계속 증가하면 할수록 일정한 DOM 개수를 유지할수 있다.
* @class
* @name eg.InfiniteGrid
* @extends eg.Component
*
* @param {HTMLElement|String|jQuery} element wrapper element <ko>기준 요소</ko>
* @param {Object} [options]
* @param {String} [options.itemSelector] selector string for layout item elements <ko>레이아웃의 아이템으로 사용될 엘리먼트들의 셀렉터</ko>
* @param {Boolean} [options.isEqualSize=false] determine if all item's size are same <ko> 모든 아이템의 사이즈가 동일한지를 지정한다</ko>
* @param {String} [options.defaultGroupKey=null] when encounter item markup during the initialization, then set `defaultGroupKey` as groupKey <ko>초기화할때 마크업에 아이템이 있다면, defalutGroupKey를 groupKey로 지정한다</ko>
* @param {Number} [options.count=30] when count value is greater than 0, grid will maintain same DOM length recycling <ko>count값이 0보다 클 경우, 그리드는 일정한 dom 개수를 유지한다</ko>
*
* @codepen {"id":"zvrbap", "ko":"InfiniteGrid 데모", "en":"InfiniteGrid example", "collectionId":"DPYEww", "height": 403}
* @support {"ie": "8+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "ios" : "7+", "an" : "2.1+ (except 3.x)"}
*
* @see Outlayer {@link https://github.com/metafizzy/outlayer}
*
* @example
<!-- HTML -->
<ul id="grid">
<li class="item">
<div>테스트1</div>
</li>
<li class="item">
<div>테스트2</div>
</li>
<li class="item">
<div>테스트3</div>
</li>
<li class="item">
<div>테스트4</div>
</li>
<li class="item">
<div>테스트5</div>
</li>
<li class="item">
<div>테스트6</div>
</li>
</ul>
<script>
var some = new eg.InfiniteGrid("#grid", {
itemSelector : ".item"
}).on("layoutComplete", function(e) {
// ...
});
</script>
*/
var EVENTS = {
"layoutComplete": "layoutComplete"
};
ns.InfiniteGrid = ns.Class.extend(ns.Component, {
_events: function() {
return EVENTS;
},
construct: function(el, options, _prefix) {
var opts = $.extend({
"isEqualSize": false,
"defaultGroupKey": null,
"count": 30
}, options);
opts.transitionDuration = 0; // don't use this option.
opts.isInitLayout = false; // isInitLayout is always 'false' in order to controll layout.
opts.isResizeBound = false; // isResizeBound is always 'false' in order to controll layout.
// if el is jQuery instance, el should change to HTMLElement.
if (el instanceof $) {
el = el.get(0);
}
this._prefix = _prefix || "";
this.core = new InfiniteGridCore(el, opts)
.on(EVENTS.layoutComplete, $.proxy(this._onlayoutComplete, this));
this.$global = $(global);
this._reset();
this.core.$element.children().length > 0 && this.layout();
this._onResize = $.proxy(this._onResize, this);
this.$global.on("resize", this._onResize);
},
_onResize: function() {
if (this.resizeTimeout) {
clearTimeout(this.resizeTimeout);
}
var self = this;
function delayed() {
self.core.element.style.width = null;
self.core.needsResizeLayout() && self.layout();
delete self.resizeTimeout;
}
this.resizeTimeout = setTimeout(delayed, 100);
},
/**
* Get current status
* @ko infiniteGrid의 현재상태를 반환한다.
* @method eg.InfiniteGrid#getStatue
* @return {Object} infiniteGrid status Object<ko>infiniteGrid 상태 오브젝트</ko>
*/
getStatus: function() {
var data = [];
var p;
for (p in this) {
if (this.hasOwnProperty(p) && /^_/.test(p)) {
data.push(p);
}
}
return {
core: this.core.clone({}, this.core),
data: clone({}, this, data),
html: this.core.$element.html(),
cssText: this.core.element.style.cssText
};
},
/**
* Set current status
* @ko infiniteGrid의 현재상태를 설정한다.
* @method eg.InfiniteGrid#setStatus
* @param {Object} status Object
* @return {eg.InfiniteGrid} instance of itself<ko>자신의 인스턴스</ko>
*/
setStatus: function(status) {
this.core.element.style.cssText = status.cssText;
this.core.$element.html(status.html);
this.core.items = this.core.itemize(this.core.$element.children().toArray());
this.core.clone(this.core, status.core);
$.extend(this, status.data);
return this;
},
/**
* Check if element is appending or prepending
* @ko append나 prepend가 진행중일 경우 true를 반환한다.
* @method eg.InfiniteGrid#isProcessing
* @return {Boolean}
*/
isProcessing: function() {
return this._isProcessing;
},
/**
* Check if elements are in recycling mode
* @ko recycle 모드 여부를 반환한다.
* @method eg.InfiniteGrid#isRecycling
* @return {Boolean}
*/
isRecycling: function() {
return this.core.options.count > 0 && this._isRecycling;
},
/**
* Get group keys
* @ko 그룹키들을 반환한다.
* @method eg.InfiniteGrid#getGroupKeys
* @return {Array} groupKeys
*/
getGroupKeys: function() {
var result = [];
if (this.core._isLayoutInited) {
var i = 0;
var item;
while (item = this.core.items[i++]) {
result.push(item.groupKey);
}
}
return result;
},
/**
* Rearrange layout
* @ko 레이아웃을 재배치한다.
* @method eg.InfiniteGrid#layout
* @return {eg.InfiniteGrid} instance of itself<ko>자신의 인스턴스</ko>
*/
layout: function() {
this._isProcessing = true;
this._isAppendType = true;
var i = 0;
var v;
while (v = this.core.items[i++]) {
v.isAppend = true;
}
this.core.layout();
return this;
},
/**
* Append elements
* @ko 엘리먼트를 append 한다.
* @method eg.InfiniteGrid#append
* @param {Array|String|jQuery} elements to be appended elements <ko>append될 엘리먼트 배열</ko>
* @param {Number|String} [groupKey] to be appended groupkey of elements<ko>append될 엘리먼트의 그룹키</ko>
* @return {Number} length a number of elements
*/
append: function($elements, groupKey) {
if (this._isProcessing || $elements.length === 0) {
return;
}
// convert jQuery instance
$elements = $($elements);
this._isProcessing = true;
if (!this._isRecycling) {
this._isRecycling =
(this.core.items.length + $elements.length) >= this.core.options.count;
}
this._insert($elements, groupKey, true);
return $elements.length;
},
/**
* Prepend elements
* @ko 엘리먼트를 prepend 한다.
* @method eg.InfiniteGrid#prepend
* @param {Array|String|jQuery} elements to be prepended elements <ko>prepend될 엘리먼트 배열</ko>
* @param {Number|String} [groupKey] to be prepended groupkey of elements<ko>prepend될 엘리먼트의 그룹키</ko>
* @return {Number} length a number of elements
*/
prepend: function($elements, groupKey) {
if (!this.isRecycling() || this._removedContent === 0 ||
this._isProcessing || $elements.length === 0) {
return;
}
// convert jQuery instance
$elements = $($elements);
this._isProcessing = true;
this._fit();
if ($elements.length - this._removedContent > 0) {
$elements = $elements.slice($elements.length - this._removedContent);
}
this._insert($elements, groupKey, false);
return $elements.length;
},
/**
* Clear elements and data
* @ko 엘리먼트와 데이터를 지운다.
* @method eg.InfiniteGrid#clear
* @return {eg.InfiniteGrid} instance of itself<ko>자신의 인스턴스</ko>
*/
clear: function() {
this.core.$element.empty();
this.core.items.length = 0;
this._reset();
this.layout();
return this;
},
_getTopItem: function() {
var item = null;
var min = Infinity;
$.each(this.core.getColItems(false), function(i, v) {
if (v && v.position.y < min) {
min = v.position.y;
item = v;
}
});
return item;
},
/**
* Get the first element at the top
* @ko 가장 위에 있는 엘리먼트를 반환한다.
* @method eg.InfiniteGrid#getTopElement
*
* @return {HTMLElement} element
*/
getTopElement: function() {
var item = this._getTopItem();
return item && item.element;
},
_getBottomItem: function() {
var item = null;
var max = -Infinity;
$.each(this.core.getColItems(true), function(i, v) {
if (v && v.position.y + v.size.outerHeight > max) {
max = v.position.y + v.size.outerHeight;
item = v;
}
});
return item;
},
/**
* Get the last element at the bottom
* @ko 가장 아래에 있는 엘리먼트를 반환한다.
* @method eg.InfiniteGrid#getBottomElement
*
* @return {HTMLElement} element
*/
getBottomElement: function() {
var item = this._getBottomItem();
return item && item.element;
},
_onlayoutComplete: function(e) {
var distance = 0;
var isAppend = this._isAppendType;
if (isAppend === false) {
this._isFitted = false;
this._fit(true);
distance = e.length >= this.core.items.length ?
0 : this.core.items[e.length].position.y;
}
var item;
var i = 0;
while (item = e[i++]) {
if (typeof item.oldVisibility !== "undefined") {
item.element.style.visibility = item.oldVisibility;
delete item.oldVisibility;
}
}
// reset flags
this._reset(true);
/**
* Occurs when layout is completed (after append / after prepend / after layout)
* @ko 레이아웃이 완료 되었을 때 발생하는 이벤트 (append/prepand/layout 메소드 호출 후, 아이템의 배치가 완료되었을때 발생)
* @name eg.InfiniteGrid#layoutComplete
* @event
*
* @param {Object} param
* @param {Array} param.target target rearranged elements<ko>재배치된 엘리먼트들</ko>
* @param {Boolean} param.isAppend isAppend determine if append or prepend (value is true when call layout method)<ko>아이템이 append로 추가되었는지, prepend로 추가되었는지를 반한환다. (layout호출시에는 true)</ko>
* @param {Number} param.distance distance<ko>layout 전의 최상단 엘리먼트의 거리</ko>
*/
this.trigger(this._prefix + EVENTS.layoutComplete, {
target: e.concat(),
isAppend: isAppend,
distance: distance
});
},
// $elements => $([HTMLElement, HTMLElement, ...])
_insert: function($elements, groupKey, isAppend) {
if ($elements.length === 0) {
return;
}
this._isAppendType = isAppend;
var elements = $elements.toArray();
var i = 0;
var item;
var items = this.core.itemize(elements, groupKey);
while (item = items[i++]) {
item.isAppend = isAppend;
item.oldVisibility = item.element.style.visibility;
item.element.style.visibility = "hidden";
}
if (isAppend) {
this.core.items = this.core.items.concat(items);
} else {
this.core.items = items.concat(this.core.items.slice(0));
items = items.reverse();
}
if (this.isRecycling()) {
this._adjustRange(isAppend, $elements);
}
var noChild = this.core.$element.children().length === 0;
this.core.$element[isAppend ? "append" : "prepend"]($elements);
noChild && this.core.resetLayout(); // for init-items
var needCheck = this._checkImageLoaded($elements);
var checkCount = needCheck.length;
checkCount > 0 ? this._waitImageLoaded(items, needCheck) :
this.core.layoutItems(items, true);
},
_adjustRange: function (isTop, $elements) {
var diff = this.core.items.length - this.core.options.count;
var targets;
var idx;
if (diff <= 0 || (idx = this._getDelimiterIndex(isTop, diff)) < 0) {
return;
}
if (isTop) {
targets = this.core.items.slice(0, idx);
this.core.items = this.core.items.slice(idx);
this._isFitted = false;
} else {
targets = this.core.items.slice(idx);
this.core.items = this.core.items.slice(0, idx);
}
// @todo improve performance
var i = 0;
var item;
var el;
while (item = targets[i++]) {
el = item.element;
idx = $elements.index(el);
if (idx !== -1) {
$elements.splice(idx, 1);
} else {
el.parentNode.removeChild(el);
}
}
this._removedContent += isTop ? targets.length : -targets.length;
},
_getDelimiterIndex: function(isTop, removeCount) {
var len = this.core.items.length;
var i;
var idx = 0;
var baseIdx = isTop ? removeCount - 1 : len - removeCount;
var targetIdx = baseIdx + (isTop ? 1 : -1);
var groupKey = this.core.items[baseIdx].groupKey;
if (groupKey != null && groupKey === this.core.items[targetIdx].groupKey) {
if (isTop) {
for (i = baseIdx; i > 0; i--) {
if (groupKey !== this.core.items[i].groupKey) {
break;
}
}
idx = i === 0 ? -1 : i + 1;
} else {
for (i = baseIdx; i < len; i++) {
if (groupKey !== this.core.items[i].groupKey) {
break;
}
}
idx = i === len ? -1 : i;
}
} else {
idx = isTop ? targetIdx : baseIdx;
}
return idx;
},
// fit size
_fit: function(applyDom) {
// for caching
if (this.core.options.count <= 0) {
this._fit = function() {
return false;
};
this._isFitted = true;
return false;
}
if (this._isFitted) {
return false;
}
var item;
var height;
var i = 0;
var y = this.core.updateCols(); // for prepend
while (item = this.core.items[i++]) {
item.position.y -= y;
applyDom && item.css({
"top": item.position.y + "px"
});
}
this.core.updateCols(true); // for append
height = this.core._getContainerSize().height;
applyDom && this.core._setContainerMeasure(height, false);
this._isFitted = true;
return true;
},
/**
* Remove white space which was removed by append action.
* @ko append에 의해 제거된 빈공간을 제거한다.
* @method eg.InfiniteGrid#fit
* @return {Number} distance if empty space is removed, value is not zero. <ko>빈공간이 제거되면 0이 아닌 값을 반환</ko>
*/
fit: function() {
var item = this._getTopItem();
var distance = item ? item.position.y : 0;
this._fit(true);
return distance;
},
_reset: function(isLayoutComplete) {
if (!isLayoutComplete) {
this._isFitted = true;
this._isRecycling = false;
this._removedContent = 0;
}
this._isAppendType = null;
this._isProcessing = false;
},
_checkImageLoaded: function($elements) {
var needCheck = [];
$elements.each(function(k, v) {
if (v.nodeName === "IMG") {
!v.complete && needCheck.push(v);
} else if (v.nodeType &&
(v.nodeType === 1 || v.nodeType === 9 || v.nodeType === 11)) { // ELEMENT_NODE, DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE
needCheck = needCheck.concat($(v).find("img").filter(function(fk, fv) {
return !fv.complete;
}).toArray());
}
});
return needCheck;
},
_waitImageLoaded: function(items, needCheck) {
var core = this.core;
var checkCount = needCheck.length;
var onCheck = function(e) {
checkCount--;
$(e.target).off("load error");
checkCount <= 0 && core.layoutItems(items, true);
};
$.each(needCheck, function(k, v) {
$(v).on("load error", onCheck);
});
},
/**
* Release resources and unbind custom events
* @ko 모든 커스텀 이벤트와 자원을 해제한다.
* @method eg.InfiniteGrid#destroy
*/
destroy: function() {
if (this.core) {
this.core.destroy();
this.core = null;
}
this.$global.off("resize", this._onResize);
this.off();
}
});
});
/**
* InfiniteGrid in jQuery plugin
* @ko InfiniteGrid in jQuery plugin
* @method jQuery.infiniteGrid
* @example
<ul id="grid">
<li class="item">
<div>test1</div>
</li>
<li class="item">
<div>test3</div>
</li>
</ul>
<script>
// create
$("#grid").infiniteGrid({
itemSelector : ".item"
});
// method
$("#grid").infiniteGrid("option","itemSelector",".selected"); //Set option
$("#grid").infiniteGrid("instance"); // Return infiniteGrid instance
$("#grid").infiniteGrid("getBottomElement"); // Get bottom element
</script>
* @see eg.InfiniteGrid
*/
/**
* infiniteGrid:layoutComplete jQuery event plugin
*
* @ko infiniteGrid:layoutComplete jQuery event plugin
* @name jQuery#infiniteGrid:layoutComplete
* @event
* @example
<ul id="grid">
<li class="item">
<div>test1</div>
</li>
<li class="item">
<div>test3</div>
</li>
</ul>
<script>
// create
$("#grid").infiniteGrid({
itemSelector : ".item"
});
// event
$("#grid").on("infiniteGrid:layoutComplete",callback);
$("#grid").off("infiniteGrid:layoutComplete",callback);
$("#grid").trigger("infiniteGrid:layoutComplete",callback);
</script>
* @see eg.InfiniteGrid#event:layoutComplete
*/