ngx-zoneless-scrollbar 1.0.0 → 21.0.2
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/LICENSE +21 -0
- package/README.md +220 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Legalfina Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# ngx-zoneless-scrollbar
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/banner.png" alt="ngx-zoneless-scrollbar" width="600">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/ngx-zoneless-scrollbar)
|
|
8
|
+
[](https://www.npmjs.com/package/ngx-zoneless-scrollbar)
|
|
9
|
+
[](https://github.com/Legalfina/ngx-zoneless-scrollbar/blob/main/LICENSE)
|
|
10
|
+
[](https://github.com/Legalfina/ngx-zoneless-scrollbar/actions/workflows/publish.yml)
|
|
11
|
+
[](https://codecov.io/gh/Legalfina/ngx-zoneless-scrollbar)
|
|
12
|
+
|
|
13
|
+
A lightweight, zoneless-compatible scrollbar component for Angular. Uses native browser scrolling with CSS-styled scrollbars, designed specifically for Angular's zoneless change detection mode.
|
|
14
|
+
|
|
15
|
+
## Why ngx-zoneless-scrollbar?
|
|
16
|
+
|
|
17
|
+
Angular's zoneless mode (`provideZonelessChangeDetection()`) offers significant performance benefits, but many existing scrollbar libraries rely on Zone.js for change detection and `afterRenderEffect` callbacks that may not work correctly in zoneless mode.
|
|
18
|
+
|
|
19
|
+
**ngx-zoneless-scrollbar** solves this by:
|
|
20
|
+
|
|
21
|
+
- Using **native browser scrolling** - 100% reliable, no Zone.js dependency
|
|
22
|
+
- Using **ResizeObserver** directly - detects content changes without Angular's lifecycle
|
|
23
|
+
- Being **fully signal-based** - works seamlessly with Angular's reactive primitives
|
|
24
|
+
- Providing **CSS-styled scrollbars** - customizable appearance on all modern browsers
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
✅ **Zoneless Compatible** - Works perfectly with `provideZonelessChangeDetection()`
|
|
29
|
+
✅ **Lightweight** - No heavy dependencies, uses native browser APIs
|
|
30
|
+
✅ **Signal-based** - Exposes scrollability state as Angular signals
|
|
31
|
+
✅ **Touch Friendly** - Supports momentum scrolling on mobile devices
|
|
32
|
+
✅ **Customizable** - Easy to style with CSS variables
|
|
33
|
+
✅ **Standalone** - Works with Angular's standalone components
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install ngx-zoneless-scrollbar
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Basic Usage
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { Component } from '@angular/core';
|
|
47
|
+
import { NgxZonelessScrollbar } from 'ngx-zoneless-scrollbar';
|
|
48
|
+
|
|
49
|
+
@Component({
|
|
50
|
+
standalone: true,
|
|
51
|
+
imports: [NgxZonelessScrollbar],
|
|
52
|
+
template: `
|
|
53
|
+
<ngx-zoneless-scrollbar>
|
|
54
|
+
<div>Your scrollable content here</div>
|
|
55
|
+
</ngx-zoneless-scrollbar>
|
|
56
|
+
`,
|
|
57
|
+
styles: [
|
|
58
|
+
`
|
|
59
|
+
ngx-zoneless-scrollbar {
|
|
60
|
+
height: 400px; /* Required: Set a height for scrolling to work */
|
|
61
|
+
}
|
|
62
|
+
`,
|
|
63
|
+
],
|
|
64
|
+
})
|
|
65
|
+
export class MyComponent {}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### With Event Binding
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { Component } from '@angular/core';
|
|
72
|
+
import { NgxZonelessScrollbar, ScrollbarUpdateEvent } from 'ngx-zoneless-scrollbar';
|
|
73
|
+
|
|
74
|
+
@Component({
|
|
75
|
+
standalone: true,
|
|
76
|
+
imports: [NgxZonelessScrollbar],
|
|
77
|
+
template: `
|
|
78
|
+
<ngx-zoneless-scrollbar #scrollbar (afterUpdate)="onScrollbarUpdate($event)">
|
|
79
|
+
<div>Your content</div>
|
|
80
|
+
</ngx-zoneless-scrollbar>
|
|
81
|
+
|
|
82
|
+
<p *ngIf="scrollbar.isVerticallyScrollable()">Content is scrollable!</p>
|
|
83
|
+
`,
|
|
84
|
+
})
|
|
85
|
+
export class MyComponent {
|
|
86
|
+
onScrollbarUpdate(event: ScrollbarUpdateEvent) {
|
|
87
|
+
console.log('Vertically scrollable:', event.isVerticallyScrollable);
|
|
88
|
+
console.log('Horizontally scrollable:', event.isHorizontallyScrollable);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Programmatic Scrolling
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Component, ViewChild } from '@angular/core';
|
|
97
|
+
import { NgxZonelessScrollbar } from 'ngx-zoneless-scrollbar';
|
|
98
|
+
|
|
99
|
+
@Component({
|
|
100
|
+
standalone: true,
|
|
101
|
+
imports: [NgxZonelessScrollbar],
|
|
102
|
+
template: `
|
|
103
|
+
<ngx-zoneless-scrollbar #scrollbar>
|
|
104
|
+
<div>Your content</div>
|
|
105
|
+
</ngx-zoneless-scrollbar>
|
|
106
|
+
|
|
107
|
+
<button (click)="scrollToTop()">Scroll to Top</button>
|
|
108
|
+
`,
|
|
109
|
+
})
|
|
110
|
+
export class MyComponent {
|
|
111
|
+
@ViewChild('scrollbar') scrollbar!: NgxZonelessScrollbar;
|
|
112
|
+
|
|
113
|
+
scrollToTop() {
|
|
114
|
+
this.scrollbar.scrollTo({ top: 0, behavior: 'smooth' });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## API Reference
|
|
120
|
+
|
|
121
|
+
### Inputs
|
|
122
|
+
|
|
123
|
+
| Input | Type | Default | Description |
|
|
124
|
+
| ------------- | ---------------------------------------------- | ------------ | ---------------- |
|
|
125
|
+
| `orientation` | `'vertical' | 'horizontal' | 'auto'` | `'vertical'` | Scroll direction |
|
|
126
|
+
|
|
127
|
+
### Outputs
|
|
128
|
+
|
|
129
|
+
| Output | Type | Description |
|
|
130
|
+
| ------------- | ---------------------- | -------------------------------------- |
|
|
131
|
+
| `afterUpdate` | `ScrollbarUpdateEvent` | Emits when scrollability state changes |
|
|
132
|
+
|
|
133
|
+
### Public Properties (Signals)
|
|
134
|
+
|
|
135
|
+
| Property | Type | Description |
|
|
136
|
+
| -------------------------- | ----------------- | ------------------------------------------ |
|
|
137
|
+
| `isVerticallyScrollable` | `Signal<boolean>` | Whether content is vertically scrollable |
|
|
138
|
+
| `isHorizontallyScrollable` | `Signal<boolean>` | Whether content is horizontally scrollable |
|
|
139
|
+
|
|
140
|
+
### Public Methods
|
|
141
|
+
|
|
142
|
+
| Method | Description |
|
|
143
|
+
| ------------------------------------ | -------------------------------------- |
|
|
144
|
+
| `scrollTo(options: ScrollToOptions)` | Scroll to a specific position |
|
|
145
|
+
| `update()` | Manually trigger a scrollability check |
|
|
146
|
+
| `viewportElement` | Get the native viewport element |
|
|
147
|
+
|
|
148
|
+
## Styling
|
|
149
|
+
|
|
150
|
+
### CSS Variables
|
|
151
|
+
|
|
152
|
+
Customize the scrollbar appearance using CSS:
|
|
153
|
+
|
|
154
|
+
```css
|
|
155
|
+
ngx-zoneless-scrollbar {
|
|
156
|
+
/* Scrollbar size */
|
|
157
|
+
--scrollbar-size: 8px;
|
|
158
|
+
|
|
159
|
+
/* Track styling */
|
|
160
|
+
--scrollbar-track-color: transparent;
|
|
161
|
+
--scrollbar-track-radius: 4px;
|
|
162
|
+
|
|
163
|
+
/* Thumb styling */
|
|
164
|
+
--scrollbar-thumb-color: rgba(0, 0, 0, 0.3);
|
|
165
|
+
--scrollbar-thumb-color-hover: rgba(0, 0, 0, 0.5);
|
|
166
|
+
--scrollbar-thumb-radius: 4px;
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Custom Styles Example
|
|
171
|
+
|
|
172
|
+
```css
|
|
173
|
+
/* Dark theme scrollbar */
|
|
174
|
+
.dark-theme ngx-zoneless-scrollbar {
|
|
175
|
+
--scrollbar-thumb-color: rgba(255, 255, 255, 0.3);
|
|
176
|
+
--scrollbar-thumb-color-hover: rgba(255, 255, 255, 0.5);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Thin scrollbar */
|
|
180
|
+
.thin-scrollbar ngx-zoneless-scrollbar {
|
|
181
|
+
--scrollbar-size: 4px;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Browser Support
|
|
186
|
+
|
|
187
|
+
- ✅ Chrome 88+
|
|
188
|
+
- ✅ Firefox 64+
|
|
189
|
+
- ✅ Safari 14+
|
|
190
|
+
- ✅ Edge 88+
|
|
191
|
+
|
|
192
|
+
All browsers that support CSS `scrollbar-width` and `::-webkit-scrollbar` pseudo-elements.
|
|
193
|
+
|
|
194
|
+
## Migration from ngx-scrollbar
|
|
195
|
+
|
|
196
|
+
If you're migrating from `ngx-scrollbar` due to zoneless compatibility issues:
|
|
197
|
+
|
|
198
|
+
```html
|
|
199
|
+
<!-- Before (ngx-scrollbar) -->
|
|
200
|
+
<ng-scrollbar #scrollbar="ngScrollbar" (afterUpdate)="onUpdate(scrollbar.adapter.isVerticallyScrollable())">
|
|
201
|
+
<content />
|
|
202
|
+
</ng-scrollbar>
|
|
203
|
+
|
|
204
|
+
<!-- After (ngx-zoneless-scrollbar) -->
|
|
205
|
+
<ngx-zoneless-scrollbar #scrollbar (afterUpdate)="onUpdate($event.isVerticallyScrollable)">
|
|
206
|
+
<content />
|
|
207
|
+
</ngx-zoneless-scrollbar>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Contributing
|
|
211
|
+
|
|
212
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
213
|
+
|
|
214
|
+
## Contributors
|
|
215
|
+
|
|
216
|
+
- [Farshad Hemmati](https://github.com/farshadhemmati)
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT © [Legalfina](https://www.legalfina.com/en)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-zoneless-scrollbar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.2",
|
|
4
4
|
"description": "A lightweight, zoneless-compatible scrollbar component for Angular. Uses native browser scrolling with CSS-styled scrollbars, designed for Angular's zoneless change detection mode.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|