ng-auto-position - npm explorer
`

CSS

`css
.menu-items {
overflow-y: auto;
}
`

$3

Prevents the user from scrolling the background while the popup is active.

HTML

`html

ngAutoPosition
[referenceElement]="menuBtn"
[hideScrollTargets]="['body', '.layout-container']"
class="dropdown"
>
Menu content

``

---

🧠 Positioning Behavior Explained

* Reference is fully visible: Popup is clamped to the viewport to prevent overflow on all sides.
* Reference is partially visible: Popup remains visible and clamped to the viewport.
* Reference is outside viewport: Popup moves with the reference and can go fully off-screen. It never "freezes" or sticks in mid-air.
* Scrollable containers: Scroll parents are listened to by default so anchors inside panels/drawers stay in sync.

---

🧪 Angular Compatibility

| Angular Version | Supported |
| :---- | :---- |
| 16+ | ✅ |

---

📄 License

MIT © Roshan

🔗 Links

* npm: https://www.npmjs.com/package/ng-auto-position
* GitHub: https://github.com/roshan2197/ng-auto-position