Skip to content

Commit

Permalink
Add demo app for cancellation of handle movement on page scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
dolezaljan committed Jul 11, 2024
1 parent 8484dc6 commit d38af6e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/demo-app/app/app-router.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LimitedRangeSliderComponent,
LimitedSliderComponent,
NoSwitchingRangeSliderComponent,
PreventChangeOnScrollSliderComponent,
PushRangeSliderComponent,
RangeSliderComponent,
ReactiveFormRangeSliderComponent,
Expand All @@ -34,6 +35,7 @@ export const routerConfig: Routes = [
{ path: 'limited-range-slider', component: LimitedRangeSliderComponent },
{ path: 'limited-slider', component: LimitedSliderComponent },
{ path: 'no-switching-range-slider', component: NoSwitchingRangeSliderComponent },
{ path: 'prevent-change-on-scroll-slider', component: PreventChangeOnScrollSliderComponent },
{ path: 'push-range-slider', component: PushRangeSliderComponent },
{ path: 'range-slider', component: RangeSliderComponent },
{ path: 'reactive-form-range-slider', component: ReactiveFormRangeSliderComponent },
Expand Down
2 changes: 2 additions & 0 deletions src/demo-app/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
LogScaleSliderComponent,
ManualRefreshSliderComponent,
NoSwitchingRangeSliderComponent,
PreventChangeOnScrollSliderComponent,
PushRangeSliderComponent,
RangeSliderComponent,
ReactiveFormRangeSliderComponent,
Expand Down Expand Up @@ -96,6 +97,7 @@ import { routerConfig, routerOptions } from './app-router.config';
LogScaleSliderComponent,
ManualRefreshSliderComponent,
NoSwitchingRangeSliderComponent,
PreventChangeOnScrollSliderComponent,
PushRangeSliderComponent,
RangeSliderComponent,
ReactiveFormRangeSliderComponent,
Expand Down
1 change: 1 addition & 0 deletions src/demo-app/app/demos.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<app-limited-slider></app-limited-slider>
<app-limited-range-slider></app-limited-range-slider>
<app-no-switching-range-slider></app-no-switching-range-slider>
<app-prevent-change-on-scroll-slider></app-prevent-change-on-scroll-slider>
<app-push-range-slider></app-push-range-slider>
<app-selection-bar-slider></app-selection-bar-slider>
<app-selection-bar-at-end-slider></app-selection-bar-at-end-slider>
Expand Down
1 change: 1 addition & 0 deletions src/demo-app/app/snippets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export * from './limited-slider/limited-slider.component';
export * from './log-scale-slider/log-scale-slider.component';
export * from './manual-refresh-slider/manual-refresh-slider.component';
export * from './no-switching-range-slider/no-switching-range-slider.component';
export * from './prevent-change-on-scroll-slider/prevent-change-on-scroll-slider.component';
export * from './push-range-slider/push-range-slider.component';
export * from './range-slider/range-slider.component';
export * from './reactive-form-range-slider/reactive-form-range-slider.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prevent-change-on-scroll-slider
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p>Value: <input type="number" [(ngModel)]="value"></p>
<ngx-slider [(value)]="value" [options]="options" [cancelHandleMovement]="emitOnScroll"></ngx-slider>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent change on page scroll slider
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, HostListener, EventEmitter } from '@angular/core';
import { Options } from '@local/ngx-slider';

@Component({
selector: 'app-prevent-change-on-scroll-slider',
templateUrl: './prevent-change-on-scroll-slider.component.html'
})
export class PreventChangeOnScrollSliderComponent {
value: number = 100;
options: Options = {
floor: 0,
ceil: 250
};
emitOnScroll: EventEmitter<void> = new EventEmitter<void>;

@HostListener('window:scroll', ['$event'])
public onScroll(event: any): void {
this.emitOnScroll.emit();
}
}

0 comments on commit d38af6e

Please sign in to comment.