|
341 | 341 | }, |
342 | 342 |
|
343 | 343 | // Render method 1: full refesh |
| 344 | + // ---- |
| 345 | + // Full list of keys is pulled from the collection, then sorted, filtered, |
| 346 | + // and interated to create (or reuse) existing instances |
344 | 347 | _applyFullRefresh: function() { |
345 | 348 | var c = this.collection; |
346 | 349 | // Start with unordered keys for view sort, |
|
391 | 394 | return this.collection.getKey(a) - this.collection.getKey(b); |
392 | 395 | }, |
393 | 396 |
|
| 397 | + // Render method 2: incremental update using splices with user sort applied |
| 398 | + // ---- |
| 399 | + // Removed/added keys are deduped, all removed rows are detached and pooled |
| 400 | + // first, and added rows are insertion-sorted into place using user sort |
394 | 401 | _applySplicesUserSort: function(splices) { |
395 | 402 | var c = this.collection; |
396 | 403 | var keys = this._keys; |
|
484 | 491 | return idx; |
485 | 492 | }, |
486 | 493 |
|
| 494 | + // Render method 3: incremental update using splices with array sort |
| 495 | + // ---- |
| 496 | + // Splices are processed in order; removed rows are pooled, and added |
| 497 | + // rows are inserted based on splice index; placeholders are used when |
| 498 | + // inserting rows when pool is empty, and placeholders are updated to |
| 499 | + // actual rows at the end to take full advantage of removed rows |
487 | 500 | _applySplicesArrayOrder: function(splices) { |
488 | 501 | var keys = this._keys; |
489 | 502 | var pool = []; |
|
500 | 513 | } |
501 | 514 | } |
502 | 515 | this._instances.splice(s.index, s.removed.length); |
503 | | - // Insert new instances (from pool or placeholder) |
| 516 | + // Insert placeholders for new rows |
504 | 517 | for (var i=0; i<s.added.length; i++) { |
505 | | - var inst; |
506 | | - if (pool.length) { |
507 | | - inst = this._insertRow(s.index + i, pool, s.added[i]); |
508 | | - } else { |
509 | | - var beforeRow = this._instances[s.index + i]; |
510 | | - inst = { |
511 | | - isPlaceholder: true, |
512 | | - key: s.added[i], |
513 | | - _children: [beforeRow ? beforeRow._children[0] : null] |
514 | | - }; |
515 | | - } |
| 518 | + var beforeRow = this._instances[s.index + i]; |
| 519 | + var inst = { |
| 520 | + isPlaceholder: true, |
| 521 | + key: s.added[i], |
| 522 | + _children: [beforeRow ? beforeRow._children[0] : this] |
| 523 | + }; |
516 | 524 | this._instances.splice(s.index + i, 0, inst); |
517 | 525 | } |
518 | 526 | }, this); |
|
0 commit comments