Page Transition Animation in Ionic 2

后端 未结 2 1105
深忆病人
深忆病人 2021-01-13 23:01

I have simple tabs template Ionic 3 application in which, I am switching between the tabs whenever user swipes on view based on left or right I am switching between Tabs and

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 23:06

    Late answer but may be useful for future users. You can achieve transition animation by this code. This question title & description is different. So I'm posting answer for title

    goTo(page, params) {  //params are optional leave blank {} if you are not sending data
        this.navCtrl.push(page, { params: params }, { animate: true, animation: 'transition', duration: 500, direction: 'forward' });
    }
    
    goBack(){
        this.navCtrl.pop({animate:true,animation:'transition',duration:500,direction:'back'});
    }
    

    Note- If you are BackButton in Navbar do this

    import {ViewChild } from '@angular/core';
    import { Navbar } from 'ionic-angular';  
    
    //create global variable
    @ViewChild(Navbar) navBar: Navbar;
    
    //inside ionViewDidLoad override back button
    ionViewDidLoad() {
    console.log('ionViewDidLoad ProductPage');
    this.navBar.backButtonClick = (e: UIEvent) => {
            // todo something
            console.log("Back Back");
            this.navCtrl.pop({animate:true,animation:'transition',duration:500,direction:'back'});
        }
    }
    

    If you need other animations you can Follow this Article which is good implementation of ionic-native transition but these only works on device not browser

提交回复
热议问题