ng-auto-position 0.0.7 โ†’ 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,21 @@
1
1
  # **ng-auto-position**
2
2
 
3
- ![npm](https://img.shields.io/npm/v/ng-auto-position)
4
- ![downloads](https://img.shields.io/npm/dm/ng-auto-position)
5
-
6
3
  A lightweight **Angular standalone directive** that automatically positions dropdowns, popovers, and floating panels relative to a reference element, while correctly handling scrolling, resizing, viewport boundaries, and scroll locking.
7
4
 
8
5
  This directive is designed for cases where **Angular CDK Overlay is too heavy**, but you still need **reliable, production-grade positioning**.
9
6
 
10
- ## ๐Ÿ”ด Live Demo
11
-
12
- Try it directly in your browser:
13
-
14
- ๐Ÿ‘‰ [https://ngautoposition-jysw--4200--31fc58ec.local-credentialless.webcontainer.io/](https://ngautoposition-jysw--4200--31fc58ec.local-credentialless.webcontainer.io/)
15
-
16
7
  ---
17
8
 
18
9
  ## **โœจ Features**
19
10
 
20
- - โœ… **Smart Positioning**: Auto positions popup **above or below** a reference element.
21
- - โœ… **Dynamic Tracking**: Popup **follows the reference** while scrolling (no freezing).
22
- - โœ… **Boundary Detection**: Viewport clamping when the reference is visible.
23
- - โœ… **Natural Exit**: Popup moves out of viewport when the reference fully leaves.
24
- - โœ… **Responsive**: Optional repositioning on scroll & resize.
25
- - โœ… **Layout Sync**: Optional width matching with reference element.
26
- - โœ… **UX Control**: Optional background scroll locking and internal scroll handling.
27
- - โœ… **Modern**: Standalone directive (Angular 16+), no Angular CDK dependency.
11
+ * โœ… **Smart Positioning**: Auto positions popup **above or below** a reference element.
12
+ * โœ… **Dynamic Tracking**: Popup **follows the reference** while scrolling (no freezing).
13
+ * โœ… **Boundary Detection**: Viewport clamping when the reference is visible.
14
+ * โœ… **Natural Exit**: Popup moves out of viewport when the reference fully leaves.
15
+ * โœ… **Responsive**: Optional repositioning on scroll & resize.
16
+ * โœ… **Layout Sync**: Optional width matching with reference element.
17
+ * โœ… **UX Control**: Optional background scroll locking and internal scroll handling.
18
+ * โœ… **Modern**: Standalone directive (Angular 16+), no Angular CDK dependency.
28
19
 
29
20
  ---
30
21
 
@@ -40,9 +31,9 @@ npm install ng-auto-position
40
31
 
41
32
  Apply the directive and provide the ID of the element it should anchor to.
42
33
 
43
- HTML
34
+ HTML
44
35
 
45
- ```html
36
+ ``` html
46
37
  <div
47
38
  class="flex flex-row"
48
39
  style="
@@ -56,37 +47,43 @@ HTML
56
47
  padding: 700px;
57
48
  "
58
49
  >
59
- <div>Lorem ipsum, dolor sit amet consectetur adipisicing elit.</div>
50
+ <div>
51
+ Lorem ipsum, dolor sit amet consectetur adipisicing elit.
52
+ </div>
60
53
  <div style="height: fit-content">
61
- <button style="padding: 4px; border: 2px solid" (click)="toggle()">Toggle</button>
54
+ <button style="padding: 4px; border: 2px solid" (click)="toggle()">
55
+ Toggle
56
+ </button>
62
57
  @if (show) {
63
- <div
64
- ngAutoPosition
65
- style="
58
+ <div
59
+ ngAutoPosition
60
+ style="
66
61
  width: 200px;
67
62
  height: 200px;
68
63
  border: 1px solid;
69
64
  background-color: white;
70
65
  "
71
- ></div>
66
+ ></div>
72
67
  }
73
68
  </div>
74
- <div>Lorem ipsum, dolor sit amet consectetur adipisicing elit.</div>
69
+ <div>
70
+ Lorem ipsum, dolor sit amet consectetur adipisicing elit.
71
+ </div>
75
72
  </div>
76
73
  ```
77
74
 
78
75
  Typescript
79
76
 
80
77
  ```typescript
81
- import { NgAutoPositionElementDirective } from "../ng-auto-position.directive";
82
- import { CommonModule } from "@angular/common";
83
- import { Component } from "@angular/core";
78
+ import { NgAutoPositionElementDirective } from '../ng-auto-position.directive';
79
+ import { CommonModule } from '@angular/common';
80
+ import { Component } from '@angular/core';
84
81
 
85
82
  @Component({
86
- selector: "ng-auto-position-test",
83
+ selector: 'ng-auto-position-test',
87
84
  standalone: true,
88
85
  imports: [CommonModule, NgAutoPositionElementDirective],
89
- templateUrl: "./ng-autoposition-test.component.html",
86
+ templateUrl: './ng-autoposition-test.component.html',
90
87
  })
91
88
  export class NgAutoPositionTestComponent {
92
89
  show: boolean = false;
@@ -95,21 +92,22 @@ export class NgAutoPositionTestComponent {
95
92
  this.show = !this.show;
96
93
  }
97
94
  }
95
+
98
96
  ```
99
97
 
100
98
  ---
101
99
 
102
100
  ## **โš™๏ธ API Inputs**
103
101
 
104
- | Input | Type | Default | Description |
105
- | :------------------- | :------- | :------ | :---------------------------------------------------- |
106
- | referenceElementId | string | null | ID of the reference element. |
107
- | enableAutoReposition | boolean | true | Reposition on window scroll & resize. |
108
- | debounceMs | number | 0 | Debounce delay for scroll/resize events. |
109
- | offset | number | 0 | Pixel gap between reference and popup. |
110
- | matchWidth | boolean | false | Match popup width to reference element width. |
111
- | scrollableSelector | string | null | Inner element selector to limit height/enable scroll. |
112
- | hideScrollTargets | string[] | null | IDs or classes (e.g. ['body']) to hide scrollbars. |
102
+ | Input | Type | Default | Description |
103
+ | :---- | :---- | :---- | :---- |
104
+ | referenceElementId | string | null | ID of the reference element. |
105
+ | enableAutoReposition | boolean | true | Reposition on window scroll & resize. |
106
+ | debounceMs | number | 0 | Debounce delay for scroll/resize events. |
107
+ | offset | number | 0 | Pixel gap between reference and popup. |
108
+ | matchWidth | boolean | false | Match popup width to reference element width. |
109
+ | scrollableSelector | string | null | Inner element selector to limit height/enable scroll. |
110
+ | hideScrollTargets | string[] | null | IDs or classes (e.g. ['body']) to hide scrollbars. |
113
111
 
114
112
  ---
115
113
 
@@ -119,25 +117,27 @@ export class NgAutoPositionTestComponent {
119
117
 
120
118
  Automatically constrains height and enables internal scrolling if the viewport is too small.
121
119
 
122
- HTML
120
+ HTML
123
121
 
124
- ```html
122
+ ```
125
123
  <button id="actionsBtn">Actions</button>
126
124
 
127
- <div
128
- autoPositionElement
129
- referenceElementId="actionsBtn"
130
- scrollableSelector=".menu-items"
131
- class="dropdown">
132
- <div class="menu-items"></div>
125
+ <div
126
+ autoPositionElement
127
+ referenceElementId="actionsBtn"
128
+ scrollableSelector=".menu-items"
129
+ class="dropdown"
130
+ >
131
+ <div class="menu-items">
132
+ </div>
133
133
  </div>
134
134
  ```
135
135
 
136
- CSS
136
+ CSS
137
137
 
138
138
  ```css
139
- .menu-items {
140
- overflow-y: auto;
139
+ .menu-items {
140
+ overflow-y: auto;
141
141
  }
142
142
  ```
143
143
 
@@ -145,15 +145,16 @@ CSS
145
145
 
146
146
  Prevents the user from scrolling the background while the popup is active.
147
147
 
148
- HTML
148
+ HTML
149
149
 
150
150
  ```html
151
- <div
152
- autoPositionElement
153
- referenceElementId="menuBtn"
154
- [hideScrollTargets]="['body', '.layout-container']"
155
- class="dropdown">
156
- Menu content
151
+ <div
152
+ autoPositionElement
153
+ referenceElementId="menuBtn"
154
+ [hideScrollTargets]="['body', '.layout-container']"
155
+ class="dropdown"
156
+ >
157
+ Menu content
157
158
  </div>
158
159
  ```
159
160
 
@@ -161,29 +162,29 @@ HTML
161
162
 
162
163
  ## **๐Ÿง  Positioning Behavior Explained**
163
164
 
164
- - **Reference is fully visible**: Popup is clamped to the viewport to prevent overflow on all sides.
165
- - **Reference is partially visible**: Popup remains visible and clamped to the viewport.
166
- - **Reference is outside viewport**: Popup moves with the reference and can go fully off-screen. It never "freezes" or sticks in mid-air.
165
+ * **Reference is fully visible**: Popup is clamped to the viewport to prevent overflow on all sides.
166
+ * **Reference is partially visible**: Popup remains visible and clamped to the viewport.
167
+ * **Reference is outside viewport**: Popup moves with the reference and can go fully off-screen. It never "freezes" or sticks in mid-air.
167
168
 
168
169
  ---
169
170
 
170
171
  ## **๐Ÿงช Angular Compatibility**
171
172
 
172
173
  | Angular Version | Supported |
173
- | :-------------- | :-------- |
174
- | 16+ | โœ… |
174
+ | :---- | :---- |
175
+ | 16+ | โœ… |
175
176
 
176
177
  ### **Standalone Import Example**
177
178
 
178
- TypeScript
179
+ TypeScript
179
180
 
180
181
  ```typescript
181
- import { AutoPositionElementDirective } from "ng-auto-position";
182
+ import { AutoPositionElementDirective } from '@roshan-ng/ng-auto-position';
182
183
 
183
- @Component({
184
- standalone: true,
185
- imports: [AutoPositionElementDirective],
186
- })
184
+ @Component({
185
+ standalone: true,
186
+ imports: [AutoPositionElementDirective],
187
+ })
187
188
  export class DemoComponent {}
188
189
  ```
189
190
 
@@ -195,5 +196,5 @@ MIT ยฉ Roshan
195
196
 
196
197
  ## **๐Ÿ”— Links**
197
198
 
198
- - **npm**: [https://www.npmjs.com/package/ng-auto-position](https://www.npmjs.com/package/@roshan-ng/ng-auto-position)
199
- - **GitHub**: [https://github.com/roshan2197/ng-auto-position](https://github.com/roshan/ng-auto-position)
199
+ * **npm**: [https://www.npmjs.com/package/ng-auto-position](https://www.npmjs.com/package/@roshan-ng/ng-auto-position)
200
+ * **GitHub**: [https://github.com/roshan2197/ng-auto-position](https://github.com/roshan/ng-auto-position)
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-auto-position",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Angular directive for auto positioning dropdowns and popovers",
5
5
  "private": false,
6
6
  "dependencies": {
Binary file