* Unmounts all inactive views after the specified active view. * * DOM WRITE * * @param activeView The view that is actively visible in the stack. Used to calculate which views to unmount.
(activeView: ViewController)
| 1004 | * @param activeView The view that is actively visible in the stack. Used to calculate which views to unmount. |
| 1005 | */ |
| 1006 | private unmountInactiveViews(activeView: ViewController) { |
| 1007 | // ok, cleanup time!! Destroy all of the views that are |
| 1008 | // INACTIVE and come after the active view |
| 1009 | // only do this if the views exist, though |
| 1010 | if (this.destroyed) { |
| 1011 | return; |
| 1012 | } |
| 1013 | const views = this.views; |
| 1014 | const activeViewIndex = views.indexOf(activeView); |
| 1015 | |
| 1016 | for (let i = views.length - 1; i >= 0; i--) { |
| 1017 | const view = views[i]; |
| 1018 | |
| 1019 | /** |
| 1020 | * When inserting multiple views via insertPages |
| 1021 | * the last page will be transitioned to, but the |
| 1022 | * others will not be. As a result, a DOM element |
| 1023 | * will only be created for the last page inserted. |
| 1024 | * As a result, it is possible to have views in the |
| 1025 | * stack that do not have `view.element` yet. |
| 1026 | */ |
| 1027 | const element = view.element; |
| 1028 | if (element) { |
| 1029 | if (i > activeViewIndex) { |
| 1030 | // this view comes after the active view |
| 1031 | // let's unload it |
| 1032 | lifecycle(element, LIFECYCLE_WILL_UNLOAD); |
| 1033 | this.destroyView(view); |
| 1034 | } else if (i < activeViewIndex) { |
| 1035 | // this view comes before the active view |
| 1036 | // and it is not a portal then ensure it is hidden |
| 1037 | setPageHidden(element!, true); |
| 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | private canStart(): boolean { |
| 1044 | return ( |
no test coverage detected