Prevent page scroll to the top when popup display in angular

485 views Asked by At

I have a button in the bottom of the page , once the button click, a popup display. However, the page automatically scroll all the way to the top, so I have to scroll down manually to be able to see the popup. I even added a function to scroll down to current position, but it's still no working. I would like both the screen and the popup stay at the bottom.

html file

   <button (click)=" goToBottom(); openPopup('Image',300)">CLICK FOR IMAGE</button>

typescript file

goToBottom(){
    window.scrollTo(0, document.body.scrollHeight);
  }

 openPopup(winTitle, winWidth) {
      const windowRef = this.window_S.open({
        appendTo: this.ngWinRef,
        title: winTitle,
        content: AComponent,
        width: winWidth,
        top: window.innerHeight / 3+ window.scrollY,
        left: (window.innerWidth - winWidth) / 4
      });
    }
  }
0

There are 0 answers