Disabling animation in Ionic toasts

时间:2018-04-18 18:01:13

标签: angular ionic-framework ionic2 ionic3

How can I disable animation in ionic toast?

I was able able to remove all animations by:

imports: [
   ...
    IonicModule.forRoot(MyApp, {
      animate: false // disable animation
    })
  ],

But how can I do it only for toasts or just a single toast?

1 个答案:

答案 0 :(得分:0)

您可以尝试添加自定义css类:

let toast = this.toastCtrl.create({
  message:"test",
  cssClass:"my-toast",
  position:"top",
  duration:500
})
toast.present()

在app.scss下添加类:

.my-toast{
     .toast-wrapper{
        transform: translateY(0%)!important;
     }
 }

根据吐司的位置,您可能需要调整css。