A powerful and flexible Angular library for managing scroll behavior in your applications. RTX Scroll Manager provides an intuitive way to handle scroll operations with customizable options and smooth animations. 🧪 Live Demo
- 🎯 Precise Control: Fine-tune scroll behavior with customizable options
- 🎨 Smooth Animations: Built-in support for smooth scrolling
- 🔄 Two-way Binding: Seamless integration with Angular's form controls
- 📱 Responsive: Works across all modern browsers and devices
- 🛠 TypeScript Support: Full type safety and autocompletion
- 📚 Well Documented: Comprehensive documentation and examples
npm install @ritox/scroll-manager- Import the module in your
app.module.ts:
import { rtxScrollManagerImports } from '@ritox/scroll-manager';
@NgModule({
imports: [
...rtxScrollManagerImports
]
})
export class AppModule { }- Use the directive in your template:
<div [rtxScrollManager]="scrollOptions">
<div [rtxScrollSection]="'section1'">
<!-- Your content here -->
</div>
<div [rtxScrollSection]="'section2'">
<!-- More content -->
</div>
</div>- Configure scroll options in your component:
import { Component, signal } from '@angular/core';
import { ScrollIntoViewOptions } from 'rtx-scroll-manager';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
scrollOptions = signal<ScrollIntoViewOptions>({
behavior: 'smooth',
block: 'start',
inline: 'nearest'
});
}The library supports all standard ScrollIntoViewOptions:
behavior: 'auto' | 'smooth' | 'instant'block: 'start' | 'center' | 'end' | 'nearest'inline: 'start' | 'center' | 'end' | 'nearest'
@Component({
selector: 'app-root',
template: `
<div [rtxScrollManager]="scrollOptions()">
<div class="controls">
<select [(ngModel)]="behavior" (ngModelChange)="updateBehavior($event)">
<option value="smooth">Smooth</option>
<option value="auto">Auto</option>
<option value="instant">Instant</option>
</select>
</div>
<div [rtxScrollSection]="'section1'">
<!-- Content -->
</div>
</div>
`
})
export class AppComponent {
scrollOptions = signal<ScrollIntoViewOptions>({
behavior: 'smooth',
block: 'start',
inline: 'nearest'
});
updateBehavior(behavior: ScrollBehavior) {
this.scrollOptions.update(options => ({
...options,
behavior
}));
}
}<div [rtxScrollManager]="scrollOptions()">
<nav>
<button [rtxScrollAnchor]="'section1'">Section 1</button>
<button [rtxScrollAnchor]="'section2'">Section 2</button>
</nav>
<div [rtxScrollSection]="'section1'">
<h2>Section 1</h2>
<!-- Content -->
</div>
<div [rtxScrollSection]="'section2'">
<h2>Section 2</h2>
<!-- Content -->
</div>
</div>-
Simplified Scroll Management
- No need to manually handle scroll events
- Clean, declarative syntax
- Automatic scroll position calculations
-
Enhanced User Experience
- Smooth animations out of the box
- Consistent behavior across browsers
- Accessible navigation patterns
-
Developer Friendly
- TypeScript support
- Angular integration
- Minimal configuration required
-
Performance Optimized
- Efficient scroll handling
- Minimal DOM operations
- Smooth animations
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this library in your projects.
If you encounter any issues or have questions, please open an issue on GitHub.