UNPKG

@ionic/core

Version:
4 lines • 4.52 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{d as t,H as i,i as s,e,c as a,h as o,t as n}from"./p-Ct2aBEue.js";import{g as h}from"./p-hHmYLOfE.js";import{a as r,d}from"./p-Ba9_OzSY.js";import{u as l,l as c}from"./p-B4IBdPVJ.js";import{c as u}from"./p-B-hirT0v.js";import{t as m,f as p}from"./p-DfDIY2oP.js";import{b as w}from"./p-HthJZjZ6.js";const g=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.ionNavWillLoad=s(this,"ionNavWillLoad",7),this.ionNavWillChange=s(this,"ionNavWillChange",3),this.ionNavDidChange=s(this,"ionNavDidChange",3),this.lockController=u(),this.gestureOrAnimationInProgress=!1,this.mode=w(this),this.animated=!0}swipeGestureChanged(){this.updateGestureEnabled()}swipeHandlerChanged(){this.updateGestureEnabled()}async connectedCallback(){const t=()=>{this.gestureOrAnimationInProgress=!0,this.animated&&e.getBoolean("animated",!0)?this.swipeHandler&&this.swipeHandler.onStart():this.unblockSwipeClicks=p(this.el)};this.gesture=(await import("./p-BVNUhOOf.js")).createSwipeBackGesture(this.el,(()=>!this.gestureOrAnimationInProgress&&!!this.swipeHandler&&this.swipeHandler.canStart()),(()=>t()),(t=>this.ani?.progressStep(t)),((t,i,s)=>{if(this.ani){this.ani.onFinish((()=>{this.gestureOrAnimationInProgress=!1,this.swipeHandler&&this.swipeHandler.onEnd(t)}),{oneTimeCallback:!0});let e=t?-.001:.001;t?e+=h([0,0],[.32,.72],[0,1],[1,1],i)[0]:(this.ani.easing("cubic-bezier(1, 0, 0.68, 0.28)"),e+=h([0,0],[1,0],[.68,.28],[1,1],i)[0]),this.ani.progressEnd(t?1:0,e,s)}else{const{swipeHandler:i,unblockSwipeClicks:s}=this;this.unblockSwipeClicks=void 0,s&&t&&i?.canStart()?new Promise((t=>t(i.onStart()))).then((()=>i.onEnd(!0))).finally((()=>{this.gestureOrAnimationInProgress=!1,s()})):(this.gestureOrAnimationInProgress=!1,s?.())}})),void 0===this.swipeGesture?this.swipeGesture=e.getBoolean("swipeBackEnabled","ios"===this.mode):this.updateGestureEnabled()}componentWillLoad(){this.ionNavWillLoad.emit()}updateGestureEnabled(){this.gesture&&this.gesture.enable(void 0!==this.swipeHandler&&!0===this.swipeGesture)}disconnectedCallback(){this.gesture&&(this.gesture.destroy(),this.gesture=void 0),this.unblockSwipeClicks&&(this.unblockSwipeClicks(),this.unblockSwipeClicks=void 0,this.gestureOrAnimationInProgress=!1)}async commit(t,i,s){const e=await this.lockController.lock();let o=!1;try{o=await this.transition(t,i,s)}catch(t){a("[ion-router-outlet] - Exception in commit:",t)}return e(),o}async setRouteId(t,i,s,e){return{changed:await this.setRoot(t,i,{duration:"root"===s?0:void 0,direction:"back"===s?"back":"forward",animationBuilder:e}),element:this.activeEl}}async getRouteId(){const t=this.activeEl;return t?{id:t.tagName,element:t,params:this.activeParams}:void 0}async setRoot(t,i,s){if(this.activeComponent===t&&l(i,this.activeParams))return!1;const e=this.activeEl,a=await r(this.delegate,this.el,t,["ion-page","ion-page-invisible"],i);return this.activeComponent=t,this.activeEl=a,this.activeParams=i,await this.commit(a,e,s),await d(this.delegate,e),!0}async transition(t,i,s={}){if(i===t)return!1;this.ionNavWillChange.emit();const{el:a,mode:o}=this,n=this.animated&&e.getBoolean("animated",!0),h=s.animationBuilder||this.animation||e.get("navAnimation");return await m({mode:o,animated:n,enteringEl:t,leavingEl:i,baseEl:a,deepWait:c(a),progressCallback:s.progressAnimation?t=>{void 0===t||this.gestureOrAnimationInProgress?this.ani=t:(this.gestureOrAnimationInProgress=!0,t.onFinish((()=>{this.gestureOrAnimationInProgress=!1,this.swipeHandler&&this.swipeHandler.onEnd(!1)}),{oneTimeCallback:!0}),t.progressEnd(0,0,0))}:void 0,...s,animationBuilder:h}),this.ionNavDidChange.emit(),!0}render(){return o("slot",{key:"078cdc7a63b98570746409fc08c4af80f8d7da4d"})}get el(){return this}static get watchers(){return{swipeGesture:[{swipeGestureChanged:0}],swipeHandler:[{swipeHandlerChanged:0}]}}static get style(){return":host{left:0;right:0;top:0;bottom:0;position:absolute;contain:layout size style;z-index:0}"}},[257,"ion-router-outlet",{mode:[1025],delegate:[16],animated:[4],animation:[16],swipeGesture:[1028,"swipe-gesture"],swipeHandler:[16],commit:[64],setRouteId:[64],getRouteId:[64]},void 0,{swipeGesture:[{swipeGestureChanged:0}],swipeHandler:[{swipeHandlerChanged:0}]}]),f=g,b=function(){"undefined"!=typeof customElements&&["ion-router-outlet"].forEach((t=>{"ion-router-outlet"===t&&(customElements.get(n(t))||customElements.define(n(t),g))}))};export{f as IonRouterOutlet,b as defineCustomElement}