Steps to initiate or conclude a conversation from a designated location?

I'm working on an Angular project where I have a popup dialog open. However, I want the dialog to appear from the button and close within the button itself, similar to this example: https://material.angularjs.org/latest/demo/dialog

Opening and closing location

Is there a way to achieve this functionality?

Currently, my code only opens the popup in the center of the page:

 dialogAdp() {
const dialogRef = this.dialog.open(DialogAdpComponent, {
  width: 'auto',
  data: { incomplete: true },
  disableClose: true
});

dialogRef.afterClosed().subscribe(result => {
  this.iD = result;
});
  }

Any assistance would be greatly appreciated.

Answer №1

Unfortunately, the MatDialog API currently does not provide a straightforward way to customize animations. The animations are embedded within .ts files rather than .scss files, making it difficult to override them. One possible solution is to create your own custom dialog using Angular CDK overlay. Alternatively, you could submit an issue on the Material GitHub repository, though implementation may not happen in the near future.

Various approaches can be taken to create custom overlay components, each with its own complexities. For more information on creating a "cdk overlay dialog," conducting a quick Google search should yield helpful resources on how to proceed.

Answer №2

Out of sheer curiosity, this method allows you to achieve a similar effect as shown in the example:

const dialogReference = this.dialog.open(LoginDialogComponent, {
          width: '320px',
        });
        let center = (window.innerWidth / 2) - 160;
        let yu = 0
        dialogReference.updatePosition({left: '0px'})
        const interval = setInterval(() => {
          if (center > yu) {
            yu += 20;
            dialogReference.updatePosition({ left: (yu) + 'px' })
          } else {
            clearInterval(interval);
            center = window.innerWidth;
          }
        });

        dialogReference.beforeClosed().subscribe(() => {
          yu = 0
          const interval = setInterval(() => {
            if (center > 0) {
              yu -= 15;
              dialogReference.updatePosition({ right: (yu) + 'px' })
            } else {
              clearInterval(interval);
              center = window.innerWidth;
            }
          });
        })

Remove dialogRef.beforeClose from open dialog method, and add it to the close method in Dialog Component for the same result.

onNoClick(): void {
    const elementRect = this.dialogReference._containerInstance['_elementRef']
    let yu = elementRect.nativeElement.offsetLeft;
    const interval = setInterval(() => {
      if (yu > - 160) {
        yu -= 10;
        this.dialogReference.updatePosition({ right: (yu) + 'px' })
        
      } else {
        clearInterval(interval);
        this.dialogReference.close();
      }
    });
  }

The dialog reference has an updateSize option that allows you to change dimensions on close. Just for fun!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Any tips on how to personalize the loading animation for single pages using CSS and GIFs?

presentLoading(message) { this.loading = this.loadingCtrl.create({ dismissOnPageChange: false, spinner:'hide', content:`<img class="load" src="assets/dual.gif" />`, }); this.loading.present(); } Hello there! I am working with the ...

Is it possible to utilize a service that is already being used by the imported component?

Recently, I began working with Angular2 and have been quite impressed with it. However, today I encountered a challenge: I have a reusable alert component that utilizes its own service containing business logic. My question is, can I utilize the same serv ...

Error: Cookie cannot be set due to headers already being sent

Here lies my code snippet import { Request, Response } from "express"; import { database } from "firebase-admin"; async function updateAccessToken( req: Request, res: Response, db: database.Database ) { try { await db ...

Examining Axios HttpService piping through a NestJS middleware in a unit test

A middleware function retrieves a JSON document from a microservice endpoint and appends it to the request. The good path test is successful, but I'm struggling to make the bad path test throw a ForbiddenException and stop it from invoking next(). W ...

What benefits does injecting FormBuilder offer over simply declaring it?

In reviewing the code, I observed that the FormBuilder constructor is set as a default empty constructor. export class FormDI { constructor(private fb: FormBuilder) {} private buildForm() { let form = this.fb.group({...}); } } export clas ...

Active Class in Angular Dynamic Carousel

I recently set up a dynamic carousel that pulls images directly from a node backend. While everything seems to be in working order, I've run into an issue where all the images are being displayed at once instead of sliding through one at a time. This ...

Ways to display Leaflet pins within Angular?

I've been working with Leaflet and despite extensive research, I'm still struggling to get my marker to display on the map. I've tried all the solutions available out there, including the Angular workaround recommended by Leaflet. Currently ...

The Lenis smooth scrolling feature (GSAP) is not functioning properly

I have encountered an issue with the smooth scrolling feature of gsap causing a delay on my website. This problem is only resolved when I manually go into the browser settings and disable smooth scrolling by navigating to chrome://flags/#smooth-scrolling ...

Creating Typescript types based on the values of other props: A guide

Can the TypeScript prop type be dynamically changed based on the runtime value of another prop? For instance type MyComponent = { propA: boolean | string propB: typeof propA boolean ? number : string } Is it feasible to determine the prop type of p ...

Determining User Existence in AWS DynamoDB with Node.js Before Creating New Record

Currently, I am in the process of developing an AWS Lambda function to create a new customer (lead). However, prior to the creation of the customer, there is a need to perform a check to determine if the user already exists. The identification of a custome ...

When using the TypeScript && operator, the resulting type is not determined by the second operand

Several past discussions on SO have touched upon the concept that the inferred type from && is based on the last expression. TypeScript’s failure to detect union type with an && operator Uncovering the reason behind the && opera ...

Is it necessary to include explicit overlapping imports in Angular if they are already imported in the parent component?

Do you think the title needs clarification? Feel free to offer suggestions. I've noticed that my design components are ending up with a lot of imports. Some of these imports are duplicated in the component that is importing them. I'm managing to ...

What is the correct way to test setInterval() statements within Angular?

Here is a simple code snippet I am working on: public async authenticate(username: string, password: string) { const authenticationResponse = await this.dataProvider.authenticate(username, password); if (authenticationResponse.result.code == 0) { ...

Ensure that the string functions as the primary interface

I'm working with an interface that looks like this interface Cat { color: string, weight: number, cute: Boolean, // even though all cats are cute! } Currently, I need to accomplish something similar to this const kitten: Cat = ... Object. ...

Utilizing formData.append in TypeScript to handle arrays

Hey there! I'm facing an issue while trying to send a form to my Profile endpoint. The problem lies in the 'user:{}' field, as I am unable to properly insert my array data into this specific field. Here is a breakdown of the fields within m ...

How can we limit the CSS properties that can be used in an interpolated manner by defining a restricted TS type for CSS props based on emotions?

When dealing with emotions, how can we specify a restricted TS type for the css prop to only allow certain css properties to be interpolated? For instance, consider the following scenario: // This is considered valid css = {{ color: 'white', ...

Installing the error package resulted in the following error: "Error: module 'nopt' not found."

After attempting to install node modules, I encountered the error message "Error: cannot find module 'nopt'." I tested various solutions, but none of them seemed to work. The image below shows the attached error message. { "name": "server", ...

Develop a variety of Jabber client echo bots

Hello Stackoverflow Community, I've been trying different approaches to resolve my issue, but I keep ending up with stack overflow errors. Programming Language: Typescript Main Objective: To create multiple instances of the Client Class that can be ...

Limit pasted content in an Angular contenteditable div

Is there a way to limit the input in a contenteditable div? I am developing my own WYSIWYG editor and want to prevent users from pasting content from external websites and copying styles. I want to achieve the same effect as if the content was pasted into ...

Implement SSL Encryption for IONIC Mobile Apps or Angular Web Applications

I am just beginning my journey in this field. Currently, I am using the IONIC framework to develop an application. The backends, which include authentication, storage, and a database, are hosted on Firebase. Additionally, I utilize some third-party APIs a ...