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

IgniteUI / igniteui-angular / 13416727049

19 Feb 2025 03:51PM CUT coverage: 91.602% (-0.003%) from 91.605%
13416727049

Pull #15247

github

web-flow
Merge 6c8542ad5 into b165899e8
Pull Request #15247: fix(excel-export): Get correct grid column collection from row island…

12995 of 15232 branches covered (85.31%)

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

118 existing lines in 20 files now uncovered.

26341 of 28756 relevant lines covered (91.6%)

34063.14 hits per line

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

90.32
/projects/igniteui-angular/src/lib/carousel/carousel-base.ts
1
import { AnimationReferenceMetadata, useAnimation } from '@angular/animations';
2
import { ChangeDetectorRef, EventEmitter, Inject, InjectionToken } from '@angular/core';
3
import { IgxAngularAnimationService } from '../services/animation/angular-animation-service';
4
import { AnimationPlayer, AnimationService } from '../services/animation/animation';
5
import { fadeIn, slideInLeft } from 'igniteui-angular/animations';
6
import { CarouselAnimationType, CarouselIndicatorsOrientation } from './enums';
7

8
export enum Direction { NONE, NEXT, PREV }
2✔
9

10
export interface CarouselAnimationSettings {
11
    enterAnimation: AnimationReferenceMetadata;
12
    leaveAnimation: AnimationReferenceMetadata;
13
}
14

15
export interface ICarouselComponentBase {
16
    id: string;
17
    role: string;
18
    cssClass: string;
19
    loop: boolean;
20
    pause: boolean;
21
    navigation: boolean;
22
    indicators: boolean;
23
    vertical: boolean;
24
    keyboardSupport: boolean;
25
    gesturesSupport: boolean;
26
    maximumIndicatorsCount: number;
27
    indicatorsOrientation: CarouselIndicatorsOrientation;
28
    animationType: CarouselAnimationType;
29
    total: number;
30
    current: number;
31
    interval: number;
32
    slideChanged: EventEmitter<any>;
33
    slideAdded: EventEmitter<any>;
34
    slideRemoved: EventEmitter<any>;
35
    carouselPaused: EventEmitter<any>;
36
    carouselPlaying: EventEmitter<any>;
37
    next(): void;
38
    prev(): void;
39
    play(): void;
40
    stop(): void
41
}
42

43
/** @hidden */
44
export const IGX_CAROUSEL_COMPONENT = /*@__PURE__*/new InjectionToken<ICarouselComponentBase>('IgxCarouselToken');
2✔
45

46
/** @hidden */
47
export interface IgxSlideComponentBase {
48
    direction: Direction;
49
    previous: boolean;
50
}
51

52
/** @hidden */
53
export abstract class IgxCarouselComponentBase {
54
    /** @hidden */
55
    public animationType: CarouselAnimationType = CarouselAnimationType.slide;
150✔
56

57
    /** @hidden @internal */
58
    public enterAnimationDone = new EventEmitter();
150✔
59
    /** @hidden @internal */
60
    public leaveAnimationDone = new EventEmitter();
150✔
61

62
    /** @hidden */
63
    protected currentItem: IgxSlideComponentBase;
64
    /** @hidden */
65
    protected previousItem: IgxSlideComponentBase;
66
    /** @hidden */
67
    protected enterAnimationPlayer?: AnimationPlayer;
68
    /** @hidden */
69
    protected leaveAnimationPlayer?: AnimationPlayer;
70
    /** @hidden */
71
    protected defaultAnimationDuration = 320;
150✔
72
    /** @hidden */
73
    protected animationPosition = 0;
150✔
74
    /** @hidden */
75
    protected newDuration = 0;
150✔
76
    /** @hidden */
77
    protected vertical = false;
150✔
78

79
    constructor(
80
        @Inject(IgxAngularAnimationService) private animationService: AnimationService,
150✔
81
        protected cdr: ChangeDetectorRef) {
150✔
82
    }
83

84
    /** @hidden */
85
    protected triggerAnimations() {
86
        if (this.animationType !== CarouselAnimationType.none) {
100✔
87
            if (this.animationStarted(this.leaveAnimationPlayer) || this.animationStarted(this.enterAnimationPlayer)) {
62✔
88
                requestAnimationFrame(() => {
1✔
89
                    this.resetAnimations();
1✔
90
                    this.playAnimations();
1✔
91
                });
92
            } else {
93
                this.playAnimations();
61✔
94
            }
95
        }
96
    }
97

98
    /** @hidden */
99
    protected animationStarted(animation: AnimationPlayer): boolean {
100
        return animation && animation.hasStarted();
149✔
101
    }
102

103
    /** @hidden */
104
    protected playAnimations() {
105
        this.playLeaveAnimation();
66✔
106
        this.playEnterAnimation();
66✔
107
    }
108

109
    private resetAnimations() {
110
        if (this.animationStarted(this.leaveAnimationPlayer)) {
1!
UNCOV
111
            this.leaveAnimationPlayer.reset();
×
UNCOV
112
            this.leaveAnimationDone.emit();
×
113
        }
114

115
        if (this.animationStarted(this.enterAnimationPlayer)) {
1!
UNCOV
116
            this.enterAnimationPlayer.reset();
×
UNCOV
117
            this.enterAnimationDone.emit();
×
UNCOV
118
            this.cdr.markForCheck();
×
119
        }
120
    }
121

122
    private getAnimation(): CarouselAnimationSettings {
123
        let duration;
124
        if (this.newDuration) {
132!
UNCOV
125
            duration = this.animationPosition ? this.animationPosition * this.newDuration : this.newDuration;
×
126
        } else {
127
            duration = this.animationPosition ? this.animationPosition * this.defaultAnimationDuration : this.defaultAnimationDuration;
132✔
128
        }
129

130
        const trans = this.animationPosition ? this.animationPosition * 100 : 100;
132✔
131
        switch (this.animationType) {
132✔
132
            case CarouselAnimationType.slide:
133
                return {
106✔
134
                    enterAnimation: useAnimation(slideInLeft,
135
                        {
136
                            params: {
137
                                delay: '0s',
138
                                duration: `${duration}ms`,
139
                                endOpacity: 1,
140
                                startOpacity: 1,
141
                                fromPosition: `${this.vertical ? 'translateY' : 'translateX'}(${this.currentItem.direction === 1 ? trans : -trans}%)`,
212!
142
                                toPosition: `${this.vertical ? 'translateY(0%)' : 'translateX(0%)'}`
106!
143
                            }
144
                        }),
145
                    leaveAnimation: useAnimation(slideInLeft,
146
                        {
147
                            params: {
148
                                delay: '0s',
149
                                duration: `${duration}ms`,
150
                                endOpacity: 1,
151
                                startOpacity: 1,
152
                                fromPosition: `${this.vertical ? 'translateY(0%)' : 'translateX(0%)'}`,
106!
153
                                toPosition: `${this.vertical ? 'translateY' : 'translateX'}(${this.currentItem.direction === 1 ? -trans : trans}%)`,
212!
154
                            }
155
                        })
156
                };
157
            case CarouselAnimationType.fade:
158
                return {
6✔
159
                    enterAnimation: useAnimation(fadeIn,
160
                        { params: { duration: `${duration}ms`, startOpacity: `${this.animationPosition}` } }),
161
                    leaveAnimation: null
162
                };
163
        }
164
        return {
20✔
165
            enterAnimation: null,
166
            leaveAnimation: null
167
        };
168
    }
169

170
    private playEnterAnimation() {
171
        const animation = this.getAnimation().enterAnimation;
66✔
172
        if (!animation) {
66✔
173
            return;
10✔
174
        }
175

176
        this.enterAnimationPlayer = this.animationService.buildAnimation(animation, this.getCurrentElement());
56✔
177
        this.enterAnimationPlayer.animationEnd.subscribe(() => {
56✔
178
            // TODO: animation may never end. Find better way to clean up the player
179
            if (this.enterAnimationPlayer) {
55✔
180
                this.enterAnimationPlayer.reset();
55✔
181
                this.enterAnimationPlayer = null;
55✔
182
            }
183
            this.animationPosition = 0;
55✔
184
            this.newDuration = 0;
55✔
185
            this.previousItem.previous = false;
55✔
186
            this.enterAnimationDone.emit();
55✔
187
            this.cdr.markForCheck();
55✔
188
        });
189
        this.previousItem.previous = true;
56✔
190
        this.enterAnimationPlayer.play();
56✔
191
    }
192

193
    private playLeaveAnimation() {
194
        const animation = this.getAnimation().leaveAnimation;
66✔
195
        if (!animation) {
66✔
196
            return;
13✔
197
        }
198

199
        this.leaveAnimationPlayer = this.animationService.buildAnimation(animation, this.getPreviousElement());
53✔
200
        this.leaveAnimationPlayer.animationEnd.subscribe(() => {
53✔
201
            // TODO: animation may never end. Find better way to clean up the player
202
            if (this.leaveAnimationPlayer) {
52✔
203
                this.leaveAnimationPlayer.reset();
52✔
204
                this.leaveAnimationPlayer = null;
52✔
205
            }
206
            this.animationPosition = 0;
52✔
207
            this.newDuration = 0;
52✔
208
            this.leaveAnimationDone.emit();
52✔
209
        });
210
        this.leaveAnimationPlayer.play();
53✔
211
    }
212

213
    protected abstract getPreviousElement(): HTMLElement;
214

215
    protected abstract getCurrentElement(): HTMLElement;
216
}
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