2.0.14 • Published 6 years ago

@beradrian/ngx-auto-scroll v2.0.14

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Angular 2+ auto scroll directive

Installation

npm install ngx-auto-scroll

Usage

In component:

import {NgxAutoScroll} from "ngx-auto-scroll/lib/ngx-auto-scroll.directive";

@Component({
   selector: 'sample',
   templateUrl: 'sample.component.html',
   styleUrls: ['sample.component.css'],
   directives: [NgxAutoScroll]
})

In template:

<div ngx-auto-scroll lock-y-offset="10" observe-attributes>
    <div *ngFor="let message of messages">{{ message }}</div>
</div>

Atribiutes:

Argument passed to lock-y-offset is bottom offset of scroll position in pixels after scroll container stops auto scroll. Default value is 10.

observe-attributes (optional, default - false) enable listening on attributes changes for example detect changes in font size.

Forcing scroll down

When your DOM element or its parent is hidden auto scroll won't work. There is no simple/pure way to scroll hidden element. The best way is to force scrolling down after the element is shown.

@Component({
   selector: 'sample',
   directives: [NgxAutoScroll]
})
export class SampleComponent {
    @ViewChild(NgxAutoScroll) ngxAutoScroll: NgxAutoScroll;
    
    public forceScrollDown(): void {
        this.ngxAutoScroll.forceScrollDown();
    }
}

Building

npm run build
2.0.14

6 years ago

2.0.13

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.15

6 years ago