Search code examples
typescriptionic3toast

How to check if toast is present


I want to check if toast is present if it is than I want to move the cart button

here a screenshot how it looks now:

enter image description here

How can I move the cart button up when the toast is present? Or even the whole page has to move up.

I tried this:

let toast = this.toastCtrl.create({
        message: 'Dish added to Cart',
        cssClass: 'mytoast',
        duration: 2000
      });

      toast.onDidDismiss(() => {
        console.log('Dismissed toast');
        document.querySelector('.fab').setAttribute('bottom', '10px');
      });

      document.querySelector('.fab').setAttribute('bottom', '60px');

      toast.present(toast);
    });

But that is not working


Solution

  • I just forget to pass the style to setAttribute so here is the answer:

    let toast = this.toastCtrl.create({
       message: 'Dish added to Cart',
       cssClass: 'mytoast',
       duration: 2000
    });
    
    toast.onDidDismiss(() => {
       document.querySelector('.fab').setAttribute("style", "bottom: 10px;");
    });
    toast.present(toast);
    document.querySelector('.fab').setAttribute('style','bottom:60px');