• 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

0.0
/src/carousel/engine/carousel-slide.ts
1
import { ChangeDetectorRef, QueryList, Renderer2 } from '@angular/core';
2
import { Platform } from '@angular/cdk/platform';
3
import { Observable, Subject } from 'rxjs';
4
import { ThyCarouselComponent } from '../carousel.component';
5
import { ThyDistanceVector } from '../typings';
×
6
import { ThyCarouselItemDirective } from '../carousel-item.directive';
7
import { ThyCarouselBaseEngine } from '../engine/carousel-base';
8

×
9
export class ThyCarouselSlideEngine extends ThyCarouselBaseEngine {
×
10
    constructor(thyCarouselComponent: ThyCarouselComponent, cdr: ChangeDetectorRef, renderer: Renderer2, platform: Platform) {
×
11
        super(thyCarouselComponent, cdr, renderer, platform);
12
    }
×
13

×
14
    private prepareHorizontalContext(activeIndex: number): void {
×
15
        if (activeIndex >= this.maxIndex) {
16
            this.renderer.setStyle(this.firstEl, 'left', `${this.length * this.contentWidth}px`);
17
            this.renderer.setStyle(this.lastEl, 'left', null);
×
18
        } else if (activeIndex <= 0) {
19
            this.renderer.setStyle(this.firstEl, 'left', null);
20
            this.renderer.setStyle(this.lastEl, 'left', `${-this.length * this.contentWidth}px`);
21
        } else {
×
22
            this.resetContext();
×
23
        }
24
    }
25

×
26
    private resetContext() {
27
        this.renderer.setStyle(this.lastEl, 'left', null);
28
        this.renderer.setStyle(this.firstEl, 'left', null);
×
29
    }
×
30

×
31
    initializeCarouselContents(contents: QueryList<ThyCarouselItemDirective> | null): void {
×
32
        this.initializeContents(contents);
×
33
    }
×
34

×
35
    dragging(pointerVector: ThyDistanceVector, rect: DOMRect): void {
36
        const { x } = pointerVector;
×
37
        const { width, height } = rect;
38
        this.contentWidth = width;
39
        this.contentHeight = height;
×
40
        const activeIndex = this.carouselComponent!.activeIndex;
×
41
        if (this.length > 1) {
×
42
            this.prepareHorizontalContext(activeIndex);
43
        }
×
44
        this.renderer.setStyle(this.wrapperEl, 'transform', `translate3d(${-activeIndex * this.contentWidth + x}px,0 , 0)`);
×
45
    }
×
46

×
47
    switch(to: number, from: number): Observable<void> {
48
        const switch$ = new Subject<void>();
×
49
        if (Math.abs(from - to) === 1 || from === to) {
×
50
            this.prepareHorizontalContext(to);
×
51
        }
×
52
        this.renderer.setStyle(this.wrapperEl, `transition-duration`, `${this.playTime}ms`);
×
53
        this.renderer.setStyle(this.wrapperEl, `transform`, `translate3d(${-to * this.contentWidth}px,0 , 0)`);
54
        setTimeout(() => {
×
55
            switch$.next();
56
        }, 0);
57
        setTimeout(() => {
×
58
            this.resetContext();
×
59
            this.renderer.setStyle(this.wrapperEl, `transition-duration`, `0s`);
×
60
            this.renderer.setStyle(
61
                this.wrapperEl,
62
                `transform`,
63
                `translate3d(${-((to + this.length) % this.length) * this.contentWidth}px,0 , 0)`
64
            );
65
            switch$.complete();
66
        }, this.playTime);
67
        return switch$.asObservable();
68
    }
69

70
    correctionOffset(): void {
71
        super.correctionOffset();
72
        const { activeIndex } = this.carouselComponent!;
73
        this.renderer.setStyle(this.wrapperEl, `transform`, `translate3d(${-activeIndex * this.contentWidth}px,0 , 0)`);
74
    }
75
}
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