6

I am using angular material dialog component code and want to add slide right animation on open/close duration.

openDialog() {
    this.dialog.open(DialogContentExampleDialog);
}

Thanks

2
  • check animated.css for this. You can add remove class name to do css effect easily Commented Jun 27, 2020 at 13:32
  • Any suggestions ? I'm in the same issue Commented Oct 7, 2023 at 10:18

2 Answers 2

8

Demo put this in index.hml

 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css" />

call this in component

const dialogRef = this.dialog.open(DialogContentExampleDialog,{panelClass: ['animate__animated','animate__slideInLeft']});
Sign up to request clarification or add additional context in comments.

1 Comment

This does not solve the issue fully. Clicking on the backdrop will not execute the animation. Only time this solution works is if the dialog is explicitly closed by clicking on the close icon.
5

You can use the library called ng-dialog-animation and use the service provided by this called NgDialogAnimationService, to open the dialog instead of the MatDialog.

Your component would have the following line of codes:

import { Component } from "@angular/core";
import { MatDialog } from "@angular/material/dialog";

 import { NgDialogAnimationService } from "ng-dialog-animation";

@Component({
selector: "dialog-content-example",
templateUrl: "dialog-content-example.html",
styleUrls: ["dialog-content-example.css"],
 })

export class DialogContentExample {
constructor(public dialog: NgDialogAnimationService){}

openDialog() {
const dialogRef = this.dialog.open(DialogContentExampleDialog, {
  width: "250px",
  // option1 
  animation:{to:"aside"},})

dialogRef.afterClosed().subscribe(result => {
  console.log(`Dialog result: ${result}`);
});
}
}

1 Comment

Thanks @Mina Shah I tried but its not working stackblitz.com/edit/ng-mat-dialog-animation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.