• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.76
/src/shared/directives/thy-scroll.directive.ts
1
import { Directive, ElementRef, OnInit, NgZone, OnDestroy, Output, EventEmitter, Input, inject } from '@angular/core';
2
import { Subject, Observable, Observer, fromEvent, Subscription } from 'rxjs';
3
import { takeUntil } from 'rxjs/operators';
4
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
5
import { coerceBooleanProperty } from 'ngx-tethys/util';
6

7
const passiveEventListenerOptions = <AddEventListenerOptions>normalizePassiveListenerOptions({ passive: true });
1✔
8

9
/**
10
 * @name thyScroll
11
 */
1✔
12
@Directive({
UNCOV
13
    selector: '[thyScroll]'
×
UNCOV
14
})
×
UNCOV
15
export class ThyScrollDirective implements OnInit, OnDestroy {
×
UNCOV
16
    private elementRef = inject<ElementRef<any>>(ElementRef);
×
UNCOV
17
    private ngZone = inject(NgZone);
×
UNCOV
18

×
19
    private _destroyed = new Subject<void>();
20
    private _enable = true;
UNCOV
21
    private _initialled = false;
×
22
    private _subscription: Subscription;
23

UNCOV
24
    private _elementScrolled: Observable<Event> = new Observable((observer: Observer<Event>) =>
×
UNCOV
25
        this.ngZone.runOutsideAngular(() =>
×
26
            fromEvent(this.elementRef.nativeElement, 'scroll', passiveEventListenerOptions)
×
27
                .pipe(takeUntil(this._destroyed))
×
28
                .subscribe(observer)
29
        )
30
    );
×
31

×
32
    @Input({ transform: coerceBooleanProperty })
×
33
    set thyEnable(value: boolean) {
34
        this._enable = value;
35
        if (this._initialled) {
36
            if (this._enable && this._subscription === null) {
37
                this._subscription = this._elementScrolled.subscribe(() => this.thyOnScrolled.emit(this.elementRef));
UNCOV
38
            } else {
×
UNCOV
39
                if (this._subscription) {
×
40
                    this._subscription.unsubscribe();
UNCOV
41
                    this._subscription = null;
×
42
                }
43
            }
UNCOV
44
        }
×
UNCOV
45
    }
×
46

47
    /**
48
     * @description
×
49
     *
50
     * Note: the `thyOnScrolled` emits outside of the Angular zone since the `scroll` listener
1✔
51
     * is installed within the `<root>` zone.
52
     *
53
     * Consumers need to re-enter the Angular zone theirselves when the change detection is needeed to be run:
54
     * ```ts
55
     * @Component({
1✔
56
     *   template: '<div thyScroll (thyOnScrolled)="onScrolled()"></div>'
57
     * })
58
     * class ThyScrollComponent {
59
     *   onScrolled(): void {
60
     *     console.log(Zone.current); // <root>
61
     *     console.log(NgZone.isInAngularZone()); // false
62
     *   }
63
     * }
64
     * ```
65
     */
66
    @Output() thyOnScrolled: EventEmitter<ElementRef> = new EventEmitter<ElementRef>();
67

68
    ngOnInit() {
69
        if (this._enable) {
70
            this._subscription = this._elementScrolled.subscribe(() => this.thyOnScrolled.emit(this.elementRef));
71
        }
72
        this._initialled = true;
73
    }
74

75
    ngOnDestroy() {
76
        this._destroyed.next();
77
        this._destroyed.complete();
78
    }
79

80
    getElementRef(): ElementRef<HTMLElement> {
81
        return this.elementRef;
82
    }
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc