页面未随着动画ionic3过渡

时间:2018-10-30 10:34:26

标签: ionic3

我试图通过使页面向前动画来从主页导航到聊天页面,但是页面总是从底部弹出,我的代码是

goTochat(friendId){
    this.provider.setUser(friendId);
    setTimeout(() => {
        this.navCtrl.push(ChatPage, {}, { animate: true, direction: 'forward' });
    },20)
}

我在哪里可能错了!请帮忙!

1 个答案:

答案 0 :(得分:0)

您要在Android设备上进行测试吗?我认为这是默认的动画。

如果要指定页面转换,可以使用以下方法: https://ionicframework.com/docs/native/native-page-transitions/

import { NativePageTransitions, NativeTransitionOptions } from '@ionic-native/native-page-transitions';

constructor(private nativePageTransitions: NativePageTransitions) { }

...


// example of adding a transition when a page/modal closes
ionViewWillLeave() {

 let options: NativeTransitionOptions = {
    direction: 'up',
    duration: 500,
    slowdownfactor: 3,
    slidePixels: 20,
    iosdelay: 100,
    androiddelay: 150,
    fixedPixelsTop: 0,
    fixedPixelsBottom: 60
   };

 this.nativePageTransitions.slide(options)
   .then(onSuccess)
   .catch(onError);

}


// example of adding a transition when pushing a new page
openPage(page: any) {

  this.nativePageTransitions.slide(options);
  this.navCtrl.push(page);

}