(ti: TransitionInstruction)
| 686 | } |
| 687 | |
| 688 | private prepareTI(ti: TransitionInstruction) { |
| 689 | const viewsLength = this.views.length; |
| 690 | |
| 691 | ti.opts ??= {}; |
| 692 | ti.opts.delegate ??= this.delegate; |
| 693 | |
| 694 | if (ti.removeView !== undefined) { |
| 695 | assert(ti.removeStart !== undefined, 'removeView needs removeStart'); |
| 696 | assert(ti.removeCount !== undefined, 'removeView needs removeCount'); |
| 697 | |
| 698 | const index = this.views.indexOf(ti.removeView); |
| 699 | if (index < 0) { |
| 700 | throw new Error('removeView was not found'); |
| 701 | } |
| 702 | ti.removeStart! += index; |
| 703 | } |
| 704 | if (ti.removeStart !== undefined) { |
| 705 | if (ti.removeStart < 0) { |
| 706 | ti.removeStart = viewsLength - 1; |
| 707 | } |
| 708 | if (ti.removeCount! < 0) { |
| 709 | ti.removeCount = viewsLength - ti.removeStart; |
| 710 | } |
| 711 | ti.leavingRequiresTransition = ti.removeCount! > 0 && ti.removeStart + ti.removeCount! === viewsLength; |
| 712 | } |
| 713 | |
| 714 | if (ti.insertViews) { |
| 715 | // allow -1 to be passed in to auto push it on the end |
| 716 | // and clean up the index if it's larger then the size of the stack |
| 717 | if (ti.insertStart! < 0 || ti.insertStart! > viewsLength) { |
| 718 | ti.insertStart = viewsLength; |
| 719 | } |
| 720 | ti.enteringRequiresTransition = ti.insertStart === viewsLength; |
| 721 | } |
| 722 | |
| 723 | const insertViews = ti.insertViews; |
| 724 | if (!insertViews) { |
| 725 | return; |
| 726 | } |
| 727 | assert(insertViews.length > 0, 'length can not be zero'); |
| 728 | const viewControllers = convertToViews(insertViews); |
| 729 | |
| 730 | if (viewControllers.length === 0) { |
| 731 | throw new Error('invalid views to insert'); |
| 732 | } |
| 733 | |
| 734 | // Check all the inserted view are correct |
| 735 | for (const view of viewControllers) { |
| 736 | view.delegate = ti.opts.delegate; |
| 737 | const nav = view.nav; |
| 738 | if (nav && nav !== this) { |
| 739 | throw new Error('inserted view was already inserted'); |
| 740 | } |
| 741 | if (view.state === VIEW_STATE_DESTROYED) { |
| 742 | throw new Error('inserted view was already destroyed'); |
| 743 | } |
| 744 | } |
| 745 | ti.insertViews = viewControllers; |
no test coverage detected