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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

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

66.67
/projects/igniteui-angular/src/lib/services/overlay/scroll/absolute-scroll-strategy.ts
1
import { NgZone } from '@angular/core';
2
import { IgxOverlayService } from '../overlay';
3
import { ScrollStrategy } from './scroll-strategy';
4

5
/**
6
 * On scroll reposition the overlay content.
7
 */
8
export class AbsoluteScrollStrategy extends ScrollStrategy {
9
    private _initialized = false;
956✔
10
    private _document: Document;
11
    private _overlayService: IgxOverlayService;
12
    private _id: string;
13
    private _scrollContainer: HTMLElement;
14
    private _zone: NgZone;
15

16
    constructor(scrollContainer?: HTMLElement) {
17
        super();
956✔
18
        this._scrollContainer = scrollContainer;
956✔
19
    }
20

21
    /**
22
     * Initializes the strategy. Should be called once
23
     *
24
     * @param document reference to Document object.
25
     * @param overlayService IgxOverlay service to use in this strategy.
26
     * @param id Unique id for this strategy.
27
     * ```typescript
28
     * settings.scrollStrategy.initialize(document, overlay, id);
29
     * ```
30
     */
31
    public initialize(document: Document, overlayService: IgxOverlayService, id: string) {
32
        if (this._initialized) {
41!
UNCOV
33
            return;
×
34
        }
35
        this._overlayService = overlayService;
41✔
36
        this._id = id;
41✔
37
        this._document = document;
41✔
38
        this._zone = overlayService.getOverlayById(id).ngZone;
41✔
39
        this._initialized = true;
41✔
40
    }
41

42
    /**
43
     * Attaches the strategy
44
     * ```typescript
45
     * settings.scrollStrategy.attach();
46
     * ```
47
     */
48
    public attach(): void {
49
        if (this._zone) {
41!
50
            this._zone.runOutsideAngular(() => {
41✔
51
                this.addScrollEventListener();
41✔
52
            });
53
        } else {
54
            this.addScrollEventListener();
×
55
        }
56
    }
57

58
    /**
59
     * Detaches the strategy
60
     * ```typescript
61
     * settings.scrollStrategy.detach();
62
     * ```
63
     */
64
    public detach(): void {
65
        if (this._scrollContainer) {
41!
66
            this._scrollContainer.removeEventListener('scroll', this.onScroll, true);
×
67
        } else {
68
            // Tired of this thing throwing every other time. Fix it ffs!
69
            this._document?.removeEventListener('scroll', this.onScroll, true);
41✔
70
        }
71

72
        this._initialized = false;
41✔
73
    }
74

75
    private addScrollEventListener() {
76
        if (this._scrollContainer) {
41!
77
            this._scrollContainer.addEventListener('scroll', this.onScroll, true);
×
78
        } else {
79
            this._document.addEventListener('scroll', this.onScroll, true);
41✔
80
        }
81
    }
82

83
    private onScroll = (e: Event) => {
956✔
UNCOV
84
        const overlayInfo = this._overlayService.getOverlayById(this._id);
×
UNCOV
85
        if (!overlayInfo) {
×
UNCOV
86
            return;
×
87
        }
UNCOV
88
        if (!overlayInfo.elementRef.nativeElement.contains(e.target)) {
×
UNCOV
89
            this._overlayService.reposition(this._id);
×
90
        }
91
    };
92
}
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