forked from vitalii-andriiovskyi/ngx-owl-carousel-o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubhome.component.ts
78 lines (70 loc) · 2.19 KB
/
subhome.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
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { tap } from 'node_modules/rxjs/operators';
import { CarouselData } from '../../app.component';
import { SlidesOutputData, OwlOptions } from 'ngx-owl-carousel-o';
@Component({
selector: 'owl-carousel-libdemo-subhome',
templateUrl: './subhome.component.html',
styleUrls: ['./subhome.component.sass']
})
export class SubHomeComponent implements OnInit {
currentUrl: any;
fragment: string;
carouselData: CarouselData[] = [
{ text: 'Slide 1', src: 'assets/images/350x450&text=1.png', dataHash: 'one'},
{ text: 'Slide 2', src: 'assets/images/350x650&text=2.png', dataHash: 'two'},
{ text: 'Slide 3', src: 'assets/images/350x250&text=3-fallback.png', dataHash: 'three'},
{ text: 'Slide 4', src: 'assets/images/350x250&text=4.png', dataHash: 'four'},
{ text: 'Slide 5', src: 'assets/images/350x250&text=5.png', dataHash: 'five'},
// { text: 'Slide 6', dotContent: 'text5'},
// { text: 'Slide 7', dotContent: 'text5'},
// { text: 'Slide 8', dotContent: 'text5'},
// { text: 'Slide 9', dotContent: 'text5'},
// { text: 'Slide 10', dotContent: 'text5'},
];
customOptions: OwlOptions = {
loop: true,
autoHeight: true,
nav: true,
center: true,
URLhashListener:true,
startPosition: 'URLHash',
responsive: {
0: {
items: 1
},
600: {
items: 2
},
900: {
items: 3
}
},
}
activeSlides: SlidesOutputData;
constructor(private route: ActivatedRoute,
private router: Router) { }
ngOnInit() {
this.route.fragment.pipe(
tap(fragment => this.fragment = fragment),
// tap(() => console.log(this.fragment))
).subscribe(
() => {}
);
this.route.url.pipe(
tap(url => this.currentUrl = url[0].path),
// tap(() => console.log(this.currentUrl))
).subscribe(
() => {}
)
}
moveToSS() {
this.router.navigate(['./'], {fragment: 'subhome-section-4', relativeTo: this.route});
}
getPassedData(data: any) {
this.activeSlides = data;
console.log('SubHomeComponent');
console.log(this.activeSlides);
}
}