• 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

2.56
/src/core/overlay/utils.ts
1
import { ThyPlacement, ConnectedPositionOffset } from './interface';
2
import { POSITION_MAP } from './overlay-position-map';
1✔
3
import { ConnectionPositionPair } from '@angular/cdk/overlay';
4

5
const connectionFallbackPositionsMap: { [key: string]: ThyPlacement[] } = {
6
    top: ['topLeft', 'topRight', 'bottom', 'bottomLeft', 'bottomRight'],
7
    topLeft: ['top', 'topRight', 'bottomLeft', 'bottom', 'bottomRight'],
8
    topRight: ['top', 'topLeft', 'bottomRight', 'bottom', 'bottomLeft'],
9
    bottom: ['bottomLeft', 'bottomRight', 'top', 'topLeft', 'topRight'],
10
    bottomLeft: ['bottom', 'bottomRight', 'topLeft', 'top', 'topRight'],
11
    bottomRight: ['bottom', 'bottomLeft', 'topRight', 'top', 'topLeft'],
12
    left: ['leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom'],
13
    leftTop: ['left', 'leftBottom', 'rightTop', 'right', 'rightBottom'],
14
    leftBottom: ['left', 'leftTop', 'rightBottom', 'right', 'rightTop'],
15
    right: ['rightTop', 'rightBottom', 'left', 'leftTop', 'leftBottom'],
16
    rightTop: ['right', 'rightBottom', 'leftTop', 'left', 'leftBottom'],
17
    rightBottom: ['right', 'rightTop', 'leftBottom', 'left', 'leftTop']
×
18
};
×
19

×
20
export function buildConnectedPositionOffset(placement: ThyPlacement, offset: number): ConnectedPositionOffset {
21
    const connectedPositionOffset: ConnectedPositionOffset = {};
×
22
    if (placement.startsWith('top')) {
×
23
        connectedPositionOffset.offsetY = -offset;
24
    } else if (placement.startsWith('bottom')) {
×
25
        connectedPositionOffset.offsetY = offset;
×
26
    } else if (placement.startsWith('left')) {
27
        connectedPositionOffset.offsetX = -offset;
×
28
    } else if (placement.startsWith('right')) {
×
29
        connectedPositionOffset.offsetX = offset;
30
    } else {
31
        // do nothings
32
    }
33
    return connectedPositionOffset;
×
34
}
35

36
export function buildConnectedPositionPair(placement: ThyPlacement, offset?: number, panelClassPrefix?: string): ConnectionPositionPair {
×
37
    const position: ConnectionPositionPair = {
38
        ...POSITION_MAP[placement],
×
39
        ...(offset ? buildConnectedPositionOffset(placement, offset) : null)
40
    };
×
41
    if (panelClassPrefix) {
×
42
        position.panelClass = `${panelClassPrefix}-${placement}`;
43
    }
×
44
    return position;
45
}
46

×
47
export function getFallbackPlacements(placement: ThyPlacement): ThyPlacement[] {
48
    return connectionFallbackPositionsMap[placement] || [];
49
}
50

51
/**
52
 * get flexible positions by placement, return placement position and it's fallback connection position
53
 * @example
54
 * getFlexiblePositions('top', 10, 'thy-overlay')
55
 * [{topPosition}, {topLeftPosition}, {topRightPosition}, {bottomPosition}, {bottomLeftPosition}, {bottomRightPosition},]
56
 * @returns [ConnectionPositionPair]
×
57
 */
×
58
export function getFlexiblePositions(placement: ThyPlacement, offset?: number, panelClassPrefix?: string): ConnectionPositionPair[] {
×
59
    const fallbackPlacements = getFallbackPlacements(placement);
60

61
    return [placement, ...fallbackPlacements].map(placementName => {
62
        return buildConnectedPositionPair(placementName, offset, panelClassPrefix);
×
63
    });
×
64
}
×
65

×
66
export function getPlacementByPosition(position: ConnectionPositionPair) {
67
    const keyList = ['originX', 'originY', 'overlayX', 'overlayY'];
68
    for (const placement in POSITION_MAP) {
69
        if (keyList.every(key => position[key] === POSITION_MAP[placement][key])) {
70
            return placement;
71
        }
72
    }
73
}
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