-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
/
app.component.ts
108 lines (95 loc) · 2.42 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { ChangeDetectorRef, Component, ViewChild } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { SwiperComponent } from 'src/angular/src/public-api';
import SwiperCore, {
Navigation,
Pagination,
Scrollbar,
A11y,
Virtual,
Zoom,
Autoplay,
Thumbs,
Controller,
} from '../../../../build/core';
SwiperCore.use([
Navigation,
Pagination,
Scrollbar,
A11y,
Virtual,
Zoom,
Autoplay,
Thumbs,
Controller,
]);
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
@ViewChild('swiperRef', { static: false }) swiperRef?: SwiperComponent;
show: boolean;
thumbs: any;
slides$ = new BehaviorSubject<string[]>(['']);
constructor(private cd: ChangeDetectorRef) {}
ngOnInit() {}
getSlides() {
this.slides$.next(Array.from({ length: 600 }).map((el, index) => `Slide ${index + 1}`));
}
thumbsSwiper: any;
setThumbsSwiper(swiper) {
this.thumbsSwiper = swiper;
}
controlledSwiper: any;
setControlledSwiper(swiper) {
this.controlledSwiper = swiper;
}
indexNumber = 1;
exampleConfig = { slidesPerView: 3 };
slidesPerView: number = 4;
pagination: any = false;
slides2 = ['slide 1', 'slide 2', 'slide 3'];
replaceSlides() {
this.slides2 = ['foo', 'bar'];
}
togglePagination() {
if (!this.pagination) {
this.pagination = { type: 'fraction' };
} else {
this.pagination = false;
}
}
navigation = false;
toggleNavigation() {
this.navigation = !this.navigation;
}
scrollbar: any = false;
toggleScrollbar() {
if (!this.scrollbar) {
this.scrollbar = { draggable: true };
} else {
this.scrollbar = false;
}
}
breakpoints = {
640: { slidesPerView: 2, spaceBetween: 20 },
768: { slidesPerView: 4, spaceBetween: 40 },
1024: { slidesPerView: 4, spaceBetween: 50 },
};
slides = Array.from({ length: 5 }).map((el, index) => `Slide ${index + 1}`);
virtualSlides = Array.from({ length: 600 }).map((el, index) => `Slide ${index + 1}`);
log(string) {
// console.log(string);
}
breakPointsToggle: boolean;
breakpointChange() {
this.breakPointsToggle = !this.breakPointsToggle;
this.breakpoints = {
640: { slidesPerView: 2, spaceBetween: 20 },
768: { slidesPerView: 4, spaceBetween: 40 },
1024: { slidesPerView: this.breakPointsToggle ? 7 : 5, spaceBetween: 50 },
};
}
}