Skip to content

Commit

Permalink
Merge pull request #12012 from Hapcy/12011-contextmenu-alignment-fix
Browse files Browse the repository at this point in the history
Fix #12011: align contextmenu properly when body is scrolled
  • Loading branch information
cetincakiroglu committed Nov 15, 2022
2 parents 415f1ba + 0a04090 commit 2164e70
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/app/components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,23 +333,23 @@ export class ContextMenu implements AfterViewInit, OnDestroy {
let viewport = DomHandler.getViewport();

//flip
if (left + width - document.body.scrollLeft > viewport.width) {
if (left + width - document.scrollingElement.scrollLeft > viewport.width) {
left -= width;
}

//flip
if (top + height - document.body.scrollTop > viewport.height) {
if (top + height - document.scrollingElement.scrollTop > viewport.height) {
top -= height;
}

//fit
if (left < document.body.scrollLeft) {
left = document.body.scrollLeft;
if (left < document.scrollingElement.scrollLeft) {
left = document.scrollingElement.scrollLeft;
}

//fit
if (top < document.body.scrollTop) {
top = document.body.scrollTop;
if (top < document.scrollingElement.scrollTop) {
top = document.scrollingElement.scrollTop;
}

this.containerViewChild.nativeElement.style.left = left + 'px';
Expand Down

0 comments on commit 2164e70

Please sign in to comment.