Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- ajax 사용 예시
- prisma
- angular button
- TAILWIND
- mysql if
- modal
- 검색
- 호버
- egov spring ajax 사용 예시
- angular animation
- 스크롤 이벤트 감지
- Angular Router
- 셀렉트박스 커스텀
- angular route
- 앵귤러 모달
- Oracle LISTAGG 사용 예시
- 앵귤러 애니메이션
- flex-1
- summary
- 아이오닉 스크롤 이벤트
- Ionic modal
- ApexChart
- scroll
- 모달
- formgroup
- Router
- 스크롤 이벤트
- 옵저버블
- angular modal
- route
Archives
- Today
- Total
깜놀하는 해므찌로
Angular Swiper 활용 예시 본문
반응형
SMALL
import { CommonModule } from '@angular/common';
import {
AfterViewInit,
CUSTOM_ELEMENTS_SCHEMA,
Component,
ElementRef,
OnInit,
ViewChild,
Input,
} from '@angular/core';
import Swiper, { SwiperOptions } from 'swiper';
import { IconComponent } from '../../../components/icon/icon.component';
import { ScrollAnimationDirective } from '../../../animations/scroll-animation/scroll-animation.directive';
@Component({
selector: 'index1-section',
templateUrl: './index1.section.html',
styleUrls: ['./index1.section.scss'],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
standalone: true,
imports: [CommonModule, IconComponent, ScrollAnimationDirective],
})
export class Index1Section implements OnInit {
@Input() visibleIndex!: number;
@ViewChild('time') time: ElementRef<HTMLDivElement> | undefined;
current: number = 0;
swiper!: Swiper;
timeLeft = 0;
isSwiperRunning: boolean = true;
constructor() {}
ngOnInit() {
this.setSwiper();
}
setSwiper() {
const swiperEl = document.querySelector('.index1') as any;
const options: SwiperOptions = {
effect: 'fade',
speed: 1400,
autoplay: {
delay: 5000,
disableOnInteraction: false,
},
allowTouchMove: false,
loop: true,
touchRatio: 0,
on: {
autoplayTimeLeft: (swiper, timeLeft, percentage) => {
this.timeLeft = 100 - Math.round(percentage * 100);
if (this.time) {
this.time.nativeElement.style.width = `${this.timeLeft}%`;
}
this.current = swiper.realIndex + 1;
},
},
};
this.swiper = new Swiper(swiperEl, options);
}
setSlide(slide: number): void {
this.swiper.slideTo(slide - 1);
this.current = slide - 1;
this.swiper.slideReset();
}
toggleAutoplay(): void {
if (this.swiper.autoplay.running) {
this.isSwiperRunning = false;
this.swiper.autoplay.running = false;
this.swiper.autoplay.paused = true;
} else {
this.isSwiperRunning = true;
this.swiper.autoplay.running = true;
this.swiper.autoplay.paused = false;
this.swiper.autoplay.resume();
}
}
}
반응형
LIST
'IT' 카테고리의 다른 글
앵귤러 사이드 메뉴 자동 닫힘 설정 angular side-menu / ng-container (0) | 2023.06.04 |
---|---|
앵귤러 button 버튼 찍어내기 예시 (0) | 2023.06.03 |
Angular HTMLElement & ElementRef 차이점 (0) | 2023.06.02 |
앵귤러 버튼 컴포넌트 click 이벤트 달기 (0) | 2023.06.02 |
Angular goBack 앵귤러 뒤로가기 구현 예시 (0) | 2023.06.02 |