• 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

19.05
/src/resizable/resize-handle.component.ts
1
import { OnInit, Component, ChangeDetectionStrategy, NgZone, ElementRef, inject, DestroyRef, input, output } from '@angular/core';
2
import { normalizePassiveListenerOptions } from '@angular/cdk/platform';
3
import { ThyResizeDirection, ThyResizeHandleMouseDownEvent } from './interface';
4
import { ThyResizableService } from './resizable.service';
5
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
import { fromEvent, merge } from 'rxjs';
7
import { useHostRenderer } from '@tethys/cdk/dom';
8
import { coerceBooleanProperty } from 'ngx-tethys/util';
9

10
const passiveEventListenerOptions = <AddEventListenerOptions>normalizePassiveListenerOptions({ passive: true });
11

1✔
12
/**
13
 * 定义调整手柄及方向
14
 * @name thy-resize-handle
15
 */
16
@Component({
1✔
17
    selector: 'thy-resize-handle, [thy-resize-handle]',
UNCOV
18
    exportAs: 'thyResizeHandle',
×
UNCOV
19
    template: `
×
UNCOV
20
        <ng-content></ng-content>
×
UNCOV
21
        @if (thyLine()) {
×
UNCOV
22
            <div class="thy-resizable-handle-line"></div>
×
UNCOV
23
        }
×
UNCOV
24
    `,
×
UNCOV
25
    changeDetection: ChangeDetectionStrategy.OnPush,
×
26
    host: {
27
        class: 'thy-resizable-handle',
UNCOV
28
        '[class.thy-resizable-handle-top]': `thyDirection() === 'top'`,
×
UNCOV
29
        '[class.thy-resizable-handle-right]': `thyDirection() === 'right'`,
×
UNCOV
30
        '[class.thy-resizable-handle-bottom]': `thyDirection() === 'bottom'`,
×
31
        '[class.thy-resizable-handle-left]': `thyDirection() === 'left'`,
32
        '[class.thy-resizable-handle-topRight]': `thyDirection() === 'topRight'`,
UNCOV
33
        '[class.thy-resizable-handle-bottomRight]': `thyDirection() === 'bottomRight'`,
×
34
        '[class.thy-resizable-handle-bottomLeft]': `thyDirection() === 'bottomLeft'`,
35
        '[class.thy-resizable-handle-topLeft]': `thyDirection() === 'topLeft'`,
UNCOV
36
        '[class.thy-resizable-handle-box-hover]': 'entered'
×
37
    },
38
    imports: []
39
})
UNCOV
40
export class ThyResizeHandle implements OnInit {
×
41
    private ngZone = inject(NgZone);
42
    private thyResizableService = inject(ThyResizableService);
UNCOV
43
    private host = inject<ElementRef<HTMLElement>>(ElementRef);
×
44

45
    /**
46
     * 调整方向
47
     * @type top | right | bottom | left | topRight | bottomRight | bottomLeft | topLeft
1✔
48
     */
49
    readonly thyDirection = input<ThyResizeDirection>('bottomRight');
50

51
    /**
52
     * 是否展示拖拽线
53
     * @type boolean
1✔
54
     */
55
    readonly thyLine = input(false, { transform: coerceBooleanProperty });
56

57
    /**
58
     * MouseDown 回调事件
59
     */
60
    readonly thyMouseDown = output<ThyResizeHandleMouseDownEvent>();
61

62
    private hostRenderer = useHostRenderer();
63

64
    private readonly destroyRef = inject(DestroyRef);
65

66
    ngOnInit(): void {
67
        this.thyResizableService.mouseEnteredOutsideAngular$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(entered => {
68
            if (entered) {
69
                this.hostRenderer.addClass('thy-resizable-handle-box-hover');
70
            } else {
71
                this.hostRenderer.removeClass('thy-resizable-handle-box-hover');
72
            }
73
        });
74
        this.ngZone.runOutsideAngular(() => {
75
            // Note: since Chrome 56 defaults document level `touchstart` listener to passive.
76
            // The element `touchstart` listener is not passive by default
77
            // We never call `preventDefault()` on it, so we're safe making it passive too.
78
            merge(
79
                fromEvent<MouseEvent>(this.host.nativeElement, 'mousedown', passiveEventListenerOptions),
80
                fromEvent<TouchEvent>(this.host.nativeElement, 'touchstart', passiveEventListenerOptions)
81
            )
82
                .pipe(takeUntilDestroyed(this.destroyRef))
83
                .subscribe((event: MouseEvent | TouchEvent) => {
84
                    this.thyResizableService.handleMouseDownOutsideAngular$.next(
85
                        new ThyResizeHandleMouseDownEvent(this.thyDirection(), event)
86
                    );
87
                });
88
        });
89
    }
90
}
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