| 34 | // them explicitly allow clear expression of intent and potentially more performant |
| 35 | // implementations |
| 36 | swap(index1: number, index2: number): void { |
| 37 | const startIdx = Math.min(index1, index2); |
| 38 | const endIdx = Math.max(index1, index2); |
| 39 | const endItem = this.detach(endIdx); |
| 40 | if (endIdx - startIdx > 1) { |
| 41 | const startItem = this.detach(startIdx); |
| 42 | this.attach(startIdx, endItem); |
| 43 | this.attach(endIdx, startItem); |
| 44 | } else { |
| 45 | this.attach(startIdx, endItem); |
| 46 | } |
| 47 | } |
| 48 | move(prevIndex: number, newIdx: number): void { |
| 49 | // For move operations, the detach code path is the same one used for removing |
| 50 | // DOM nodes, which would trigger `animate.leave` bindings. We need to skip |