import { Directive } from '@angular/core'; import { coerceNumberProperty } from '@angular/cdk/coercion'; import { EMPTY, fromEvent, merge, of, map, switchMap, tap } from 'rxjs'; import { preventSelection, enableSelection, stopPropagation } from '../common'; import * as i0 from "@angular/core"; import * as i1 from "../../ng-scrollbar-base"; // @dynamic export class TrackAdapter { // Stream that emits when the track element is clicked get clicked() { const mouseDown = fromEvent(this.trackElement, 'mousedown', { passive: true }).pipe(stopPropagation(), preventSelection(this.document)); const mouseup = fromEvent(this.document, 'mouseup', { passive: true }).pipe(stopPropagation(), enableSelection(this.document), switchMap(() => EMPTY)); return merge(mouseDown, mouseup); } // Get track client rect get clientRect() { return this.trackElement.getBoundingClientRect(); } constructor(cmp, trackElement, document) { this.cmp = cmp; this.trackElement = trackElement; this.document = document; } /** * Stream that emits when scrollbar track is clicked */ onTrackClicked(e, thumbSize, scrollSize) { return of(e).pipe(map((e) => e[this.pageProperty]), // Calculate scrollTo position map((pageOffset) => { const clickOffset = pageOffset - this.offset; const offset = clickOffset - (thumbSize / 2); const ratio = offset / this.size; return ratio * scrollSize; }), // Smooth scroll to position tap((value) => { this.cmp.scrollTo({ ...this.mapToScrollToOption(value), duration: coerceNumberProperty(this.cmp.trackClickScrollDuration) }); })); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: TrackAdapter, deps: [{ token: i1.NgScrollbarBase }, { token: HTMLElement }, { token: Document }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.5", type: TrackAdapter, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: TrackAdapter, decorators: [{ type: Directive }], ctorParameters: function () { return [{ type: i1.NgScrollbarBase }, { type: HTMLElement }, { type: Document }]; } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhY2suanMiLCJz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