Commit 911095ee by Adarsh K

design fix

parent 54fe6ff7
import { Directive, TemplateRef } from '@angular/core'; import { Directive, TemplateRef, Input } from '@angular/core';
@Directive({ @Directive({
selector: '[carouselItem]' selector: '[carouselItem]'
}) })
export class CarouselDirective { export class CarouselDirective {
@Input() type: string;
constructor(public tpl: TemplateRef<any>) { constructor(public tpl: TemplateRef<any>) {
this.tpl['name'] = 1;
} }
} }
\ No newline at end of file
<section class="carousel-wrapper" [ngStyle]="carouselWrapperStyle"> <section class="carousel-wrapper" [ngStyle]="carouselWrapperStyle">
<ul class="carousel-inner" #carousel> <ul class="carousel-inner" #carousel >
<li *ngFor="let item of items;" class="carousel-item" [ngStyle]="{'width.px':itemWidth}"> <li *ngFor="let item of items;" class="carousel-item" [ngStyle]="{'width.px':itemWidth}">
<ng-container [ngTemplateOutlet]="item.tpl"></ng-container> <ng-container [ngTemplateOutlet]="item.tpl"></ng-container>
</li> </li>
......
<div class="destination_slider"> <div class="destination_slider">
<carousel> <section class="carousel-wrapper" [ngStyle]="carouselWrapperStyle">
<ng-container *ngFor="let item of items;"> <div style="width: 2000px" class="carousel-inner" #carousel>
<ng-container *carouselItem> <div class="inner_slider" *ngFor="let item of items;">
<div class="inner_slider">
<div class="inner_overlay"> <div class="inner_overlay">
<h4>{{item.place}}</h4> <h4>{{item.place}}</h4>
<h6> <h6>
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
</div> </div>
<img src={{item.image}}> <img src={{item.image}}>
</div> </div>
</ng-container> </div>
</ng-container> </section>
</carousel>
</div> </div>
\ No newline at end of file
.destination_slider { .destination_slider {
padding: 10px; padding: 10px;
padding-top: 0px; padding-top: 0px;
display: flex;
.slick-slide { .slick-slide {
margin: 0 5px; margin: 0 5px;
} }
...@@ -46,3 +47,15 @@ ...@@ -46,3 +47,15 @@
} }
} }
} }
.carousel-wrapper {
min-width: 100%;
ul {
margin: 0px;
padding: 0px;
}
}
.carousel-inner {
display: flex;
width: max-content;
}
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, Input, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { animate, AnimationBuilder, AnimationFactory, AnimationPlayer, style } from '@angular/animations';
@Component({ @Component({
selector: 'ati-destination', selector: 'ati-destination',
templateUrl: './destination.component.html', templateUrl: './destination.component.html',
styleUrls: ['./destination.component.scss'] styleUrls: ['./destination.component.scss']
}) })
export class DestinationComponent implements OnInit { export class DestinationComponent implements OnInit, AfterViewInit {
items: any; items: any;
type: any;
@ViewChild('carousel', {static: false}) private carousel: ElementRef;
@Input() timing = '750ms ease-in';
@Input() showControls = true;
private player: AnimationPlayer;
private itemWidth: number;
private currentSlide = 0;
carouselWrapperStyle = {};
slideWidth: any;
constructor() { } constructor(private builder: AnimationBuilder) {
this.type = 'destination';
}
ngOnInit() { ngOnInit() {
this.items = [ this.items = [
...@@ -24,6 +36,38 @@ export class DestinationComponent implements OnInit { ...@@ -24,6 +36,38 @@ export class DestinationComponent implements OnInit {
] ]
} }
next() {
this.currentSlide = (this.currentSlide + 1) % this.items.length;
const offset = this.currentSlide * this.itemWidth;
const myAnimation: AnimationFactory = this.buildAnimation(offset);
this.player = myAnimation.create(this.carousel.nativeElement);
this.player.play();
}
private buildAnimation(offset) {
return this.builder.build([
animate(this.timing, style({ transform: `translateX(-${offset}px)` }))
]);
}
ngAfterViewInit() {
const count = this.items.length;
this.slideWidth = count * this.itemWidth;
setTimeout(() => {
// this.itemWidth = this.itemsElements.first.nativeElement.getBoundingClientRect().width;
this.itemWidth = window.innerHeight;
console.log(this.itemWidth);
this.carouselWrapperStyle = {
width: `${this.slideWidth}px`
};
});
setInterval(() => {
this.itemWidth = 50 * 4;
this.next();
}, 2000);
}
......
<div class="offer_slider"> <carousel>
<carousel>
<ng-container *ngFor="let item of items;"> <ng-container *ngFor="let item of items;">
<ng-container *carouselItem> <ng-container *carouselItem>
<div class="offer_slider">
<div class="slide"> <div class="slide">
<div class="inner_slider"> <div class="inner_slider">
<div class="content_inner"> <div class="content_inner">
...@@ -20,7 +19,8 @@ ...@@ -20,7 +19,8 @@
</div> </div>
<img src="../../../assets/offer/bottom_ribbon.png"> <img src="../../../assets/offer/bottom_ribbon.png">
</div> </div>
</div>
</ng-container> </ng-container>
</ng-container> </ng-container>
</carousel> </carousel>
</div> \ No newline at end of file
\ No newline at end of file
...@@ -8,8 +8,10 @@ import {Component, OnInit} from '@angular/core'; ...@@ -8,8 +8,10 @@ import {Component, OnInit} from '@angular/core';
export class OffersComponent { export class OffersComponent {
items: any; items: any;
type: any;
ngOnInit() { ngOnInit() {
this.type = 'offer';
this.items = [ this.items = [
{ title: 'Airfares starting at Rs. 399*', desc: 'Flights, 1080 Hotels, 410 Homestays,<br> Holiday Packages get 1080 Hotels, 410 Home..', code: 'AT 500' }, { title: 'Airfares starting at Rs. 399*', desc: 'Flights, 1080 Hotels, 410 Homestays,<br> Holiday Packages get 1080 Hotels, 410 Home..', code: 'AT 500' },
{ title: 'Airfares starting at Rs. 599*', desc: 'Flights, 1080 Hotels, 410 Homestays,<br> Holiday Packages get 1080 Hotels, 410 Home..', code: 'AT 500' }, { title: 'Airfares starting at Rs. 599*', desc: 'Flights, 1080 Hotels, 410 Homestays,<br> Holiday Packages get 1080 Hotels, 410 Home..', code: 'AT 500' },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment