From a52d50e788792a63e97a9176ab319d53db7a2853 Mon Sep 17 00:00:00 2001 From: vempo Date: Tue, 24 Jul 2018 17:34:04 +0300 Subject: Replaced old implementation at root Old project files and directories has been moved under 'deprecated-workflow-designer'. The old project is not built by the CI anymore, but can be still built manually. New modules/directories have been moved up and integrated with the CI system. Change-Id: I1528c792bcbcce9e50bfc294a1328a20e72c91cf Issue-ID: SDC-1559 Signed-off-by: vempo --- .../app/paletx/core/overlay/scroll/scrollable.ts | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/core/overlay/scroll/scrollable.ts (limited to 'deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/core/overlay/scroll/scrollable.ts') diff --git a/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/core/overlay/scroll/scrollable.ts b/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/core/overlay/scroll/scrollable.ts new file mode 100644 index 00000000..fe7b041c --- /dev/null +++ b/deprecated-workflow-designer/sdc-workflow-designer-ui/src/app/paletx/core/overlay/scroll/scrollable.ts @@ -0,0 +1,63 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +/* tslint:disable:array-type member-access variable-name typedef + only-arrow-functions directive-class-suffix component-class-suffix + component-selector*/ +import {Directive, ElementRef, NgZone, OnDestroy, OnInit, Renderer2} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Subject} from 'rxjs/Subject'; + +import {ScrollDispatcher} from './scroll-dispatcher'; + + +/** + * Sends an event when the directive's element is scrolled. Registers itself + * with the ScrollDispatcher service to include itself as part of its collection + * of scrolling events that it can be listened to through the service. + */ +@Directive({selector: '[cdk-scrollable], [cdkScrollable]'}) +export class Scrollable implements OnInit, OnDestroy { + private _elementScrolled: Subject = new Subject(); + private _scrollListener: Function|null; + + constructor( + private _elementRef: ElementRef, private _scroll: ScrollDispatcher, + private _ngZone: NgZone, private _renderer: Renderer2) {} + + ngOnInit() { + this._scrollListener = this._ngZone.runOutsideAngular(() => { + return this._renderer.listen( + this.getElementRef().nativeElement, 'scroll', (event: Event) => { + this._elementScrolled.next(event); + }); + }); + + this._scroll.register(this); + } + + ngOnDestroy() { + this._scroll.deregister(this); + + if (this._scrollListener) { + this._scrollListener(); + this._scrollListener = null; + } + } + + /** + * Returns observable that emits when a scroll event is fired on the host + * element. + */ + elementScrolled(): Observable { + return this._elementScrolled.asObservable(); + } + + getElementRef(): ElementRef { + return this._elementRef; + } +} -- cgit 1.2.3-korg