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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM UTC 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

0.0
/projects/igniteui-angular/src/lib/services/overlay/position/elastic-position-strategy.ts
1
import { ConnectedFit, HorizontalAlignment, VerticalAlignment } from '../utilities';
2
import { BaseFitPositionStrategy } from './base-fit-position-strategy';
3

4
/**
5
 * Positions the element as in **Connected** positioning strategy and resize the element
6
 * to fit in the view port in case the element is partially getting out of view
7
 */
8
export class ElasticPositionStrategy extends BaseFitPositionStrategy {
9
    /**
10
     * Fits the element into viewport according to the position settings
11
     *
12
     * @param element element to fit in viewport
13
     * @param connectedFit connectedFit object containing all necessary parameters
14
     */
15
    protected fitInViewport(element: HTMLElement, connectedFit: ConnectedFit) {
UNCOV
16
        element.classList.add('igx-overlay__content--elastic');
×
UNCOV
17
        const transformString: string[] = [];
×
UNCOV
18
        if (connectedFit.fitHorizontal.back < 0 || connectedFit.fitHorizontal.forward < 0) {
×
UNCOV
19
            const maxReduction = Math.max(0, connectedFit.contentElementRect.width - this.settings.minSize.width);
×
UNCOV
20
            const leftExtend = Math.max(0, -connectedFit.fitHorizontal.back);
×
UNCOV
21
            const rightExtend = Math.max(0, -connectedFit.fitHorizontal.forward);
×
UNCOV
22
            const reduction = Math.min(maxReduction, leftExtend + rightExtend);
×
UNCOV
23
            element.style.width = `${connectedFit.contentElementRect.width - reduction}px`;
×
24

25
            //  if direction is center and element goes off the screen in left direction we should push the
26
            //  element to the right. Prevents left still going out of view when normally positioned
UNCOV
27
            if (this.settings.horizontalDirection === HorizontalAlignment.Center) {
×
28
                //  the amount of translation depends on whether element goes off the screen to the left,
29
                //  to the right or in both directions, as well as how much it goes of the screen and finally
30
                //  on the minSize. The translation should be proportional between left and right extend
31
                //  taken from the reduction
32
                const translation = leftExtend * reduction / (leftExtend + rightExtend);
×
33
                if (translation > 0) {
×
34
                    transformString.push(`translateX(${translation}px)`);
×
35
                }
36
            }
37
        }
38

UNCOV
39
        if (connectedFit.fitVertical.back < 0 || connectedFit.fitVertical.forward < 0) {
×
UNCOV
40
            const maxReduction = Math.max(0, connectedFit.contentElementRect.height - this.settings.minSize.height);
×
UNCOV
41
            const topExtend = Math.max(0, -connectedFit.fitVertical.back);
×
UNCOV
42
            const bottomExtend = Math.max(0, -connectedFit.fitVertical.forward);
×
UNCOV
43
            const reduction = Math.min(maxReduction, topExtend + bottomExtend);
×
UNCOV
44
            element.style.height = `${connectedFit.contentElementRect.height - reduction}px`;
×
45

46
            //  if direction is middle and element goes off the screen in top direction we should push the
47
            //  element to the bottom. Prevents top still going out of view when normally positioned
UNCOV
48
            if (this.settings.verticalDirection === VerticalAlignment.Middle) {
×
49
                //  the amount of translation depends on whether element goes off the screen to the top,
50
                //  to the bottom or in both directions, as well as how much it goes of the screen and finally
51
                //  on the minSize. The translation should be proportional between top and bottom extend
52
                //  taken from the reduction
53
                const translation = topExtend * reduction / (topExtend + bottomExtend);
×
54
                if (translation > 0) {
×
55
                    transformString.push(`translateY(${translation}px)`);
×
56
                }
57
            }
58
        }
UNCOV
59
        element.style.transform = transformString.join(' ').trim();
×
60
    }
61
}
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