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

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

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

14.29
/src/color-picker/coordinates.directive.ts
1
import { Directive, ElementRef, HostListener, OnDestroy, OnInit, Output } from '@angular/core';
2
import { Subject, Subscription } from 'rxjs';
3
import { distinctUntilChanged } from 'rxjs/operators';
4

5
/**
6
 * @internal
7
 */
8
@Directive({
1✔
9
    selector: '[thyColorCoordinates]',
10
    standalone: true
×
11
})
×
12
export class ThyCoordinatesDirective implements OnInit, OnDestroy {
×
13
    @Output()
14
    coordinatesChange = new Subject<{
15
        x: number;
×
16
        y: number;
×
17
        left: number;
×
18
        top: number;
19
        containerWidth: number;
20
        containerHeight: number;
21
        $event: any;
×
22
    }>();
23

24
    private mousechange = new Subject<{
×
25
        x: number;
×
26
        y: number;
×
27
        $event: any;
×
28
    }>();
29

30
    private mouseListening = false;
×
31

×
32
    private sub?: Subscription;
×
33

34
    @HostListener('mousedown', ['$event', '$event.pageX', '$event.pageY'])
35
    mousedown($event: Event, x: number, y: number) {
×
36
        $event.preventDefault();
×
37
        this.mouseListening = true;
×
38
        this.mousechange.next({ x, y, $event });
×
39
    }
×
40

41
    @HostListener('window:mousemove', ['$event', '$event.pageX', '$event.pageY'])
42
    mousemove($event: Event, x: number, y: number) {
43
        if (this.mouseListening) {
44
            $event.preventDefault();
45
            this.mousechange.next({ x, y, $event });
46
        }
47
    }
48

49
    @HostListener('window:mouseup')
50
    mouseup() {
×
51
        this.mouseListening = false;
52
    }
1✔
53

54
    constructor(public el: ElementRef) {}
55

1✔
56
    ngOnInit() {
57
        this.sub = this.mousechange
58
            .pipe(distinctUntilChanged((last, current) => last.x === current.x && last.y === current.y))
59
            .subscribe(n => this.handleChange(n.x, n.y, n.$event));
60
    }
61

62
    handleChange(x: number, y: number, $event: Event) {
1✔
63
        const containerWidth = this.el.nativeElement.clientWidth;
64
        const containerHeight = this.el.nativeElement.clientHeight;
65
        const left = x - (this.el.nativeElement.getBoundingClientRect().left + window.pageXOffset);
66
        const top = y - (this.el.nativeElement.getBoundingClientRect().top + window.pageYOffset);
67
        this.coordinatesChange.next({
68
            x,
69
            y,
70
            top,
71
            left,
72
            containerHeight,
73
            containerWidth,
74
            $event
75
        });
76
    }
77

78
    ngOnDestroy(): void {
79
        this.sub?.unsubscribe();
80
    }
81
}
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