Angular ScrollBar Example.
Loading...

Angular ScrollBar: Default Functionality

The default functionalities in Angular ScrollBar.

A live Angular example of jqxScrollBar, the jQWidgets ScrollBar component, with its complete source code below. It is one of 2 jqxScrollBar demos for Angular.

jqxScrollBar API used in this demo

Source code

To run it in your own app, install the package with npm install jqwidgets-ng, add these files to a standalone Angular CLI app, and add jqx.base.css and a theme to the styles in angular.json. Getting started with jqxScrollBar shows the setup step by step.

app.ts

import { Component, ElementRef, viewChild } from '@angular/core';
import { CommonModule } from '@angular/common';
import { jqxScrollBarModule } from 'jqwidgets-ng/jqxscrollbar';

@Component({
    imports: [CommonModule, jqxScrollBarModule],
    selector: 'app-root',
    templateUrl: './app.html'
})

export class App {
    readonly HorizontalDiv = viewChild.required<ElementRef>('HorizontalDiv');
    readonly VerticalDiv = viewChild.required<ElementRef>('VerticalDiv');

    onValueChangedVertical(event: any): void {
        this.VerticalDiv().nativeElement.innerHTML = 'Vertical (' + parseInt(event.currentValue) + ')';
    };

    onValueChangedHorizontal(event: any): void {
        this.HorizontalDiv().nativeElement.innerHTML = 'Horizontal (' + parseInt(event.currentValue) + ')';
    };
}

app.html

<div style="margin-bottom: 10px;" #VerticalDiv>Vertical</div>
<jqxScrollBar (onValueChanged)="onValueChangedVertical($event)"
              [width]="18" [height]="280"
              [min]="0" [max]="1000" [vertical]="true">
</jqxScrollBar>
<div style="margin: 10px 0;" #HorizontalDiv>Horizontal</div>
<jqxScrollBar (onValueChanged)="onValueChangedHorizontal($event)"
              [width]="280" [height]="18"
              [min]="0" [max]="1000">
</jqxScrollBar>

Learn more

More Angular ScrollBar demos