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 |
Tags
- 셀렉트박스 커스텀
- 검색
- 스크롤 이벤트 감지
- 옵저버블
- 호버
- angular modal
- modal
- Oracle LISTAGG 사용 예시
- 아이오닉 스크롤 이벤트
- Ionic modal
- ajax 사용 예시
- 앵귤러 애니메이션
- formgroup
- summary
- scroll
- 모달
- flex-1
- 스크롤 이벤트
- angular animation
- angular route
- 앵귤러 모달
- Router
- route
- TAILWIND
- egov spring ajax 사용 예시
- mysql if
- prisma
- Angular Router
- angular button
- ApexChart
Archives
- Today
- Total
깜놀하는 해므찌로
Swiper silde vertical 수직 슬라이드 구현 예시 / 랜덤 이미지 가져오기 / tailwind group class 이름 가져오기 본문
IT
Swiper silde vertical 수직 슬라이드 구현 예시 / 랜덤 이미지 가져오기 / tailwind group class 이름 가져오기
agnusdei1207 2023. 6. 30. 12:43반응형
SMALL
<div class="flex flex-col md:flex-row text-white gap-32 z-10 w-[400px]">
<swiper-container init="false" class="section3" style="width: 100%; height: 100%">
// 클래스 명 = 'group' 설정
<swiper-slide class="group" *ngFor="let video of videos">
<img [src]="video.image" />
// 그룹 클래스 내에 '.swiper-slide-next' 라는 클래스가 있다면 felx 없다면 hidden
<div class="group-[.swiper-slide-next]:flex hidden flex-col">
<span class="text-lg text-white font-semibold"
>{{video.title}}</span
>
<small class="text-neutral-600">{{video.year}}</small>
</div>
</swiper-slide>
</swiper-container>
</div>
0. init="flase" 스와이퍼를 커스텀한 대로 적용하기 전까지 임의로 스와이퍼를 그리지 말라는 지시
1. 템플릿: 슬라이드 구현을 위해 swiper-container, swiper-slide 태그를 사용
전용 태그를 사용하지 않고 div 만으로도 구현이 가능합니다. 제일 하단 참조!
import { CommonModule } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA, Component, OnInit } from '@angular/core';
import Swiper from 'swiper'; // 스와이퍼
import { register } from 'swiper/element'; // 스와이퍼
register(); // 스와이퍼
@Component({
selector: 'app-section3',
standalone: true,
imports: [CommonModule, IconComponent],
templateUrl: './section3.section.html',
styleUrls: ['./section3.section.scss'],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class Section3Section implements OnInit {
videos: { image: string; title: string; year: number }[] = [
{
image: 'https://picsum.photos/400/300', // 랜덤이미지 가져오기 width/height
title: 'title1',
year: 2023,
},
{
image: 'https://picsum.photos/400/300',
title: 'title2',
year: 2023,
},
{
image: 'https://picsum.photos/400/300',
title: 'title3',
year: 2023,
},
{
image: 'https://picsum.photos/400/300',
title: 'title4',
year: 2023,
},
];
swiper!: Swiper; // Swiper 객체 선언
constructor() {}
ngAfterViewInit(): void { // AfterViewInit 후크에 사용하길 권장
this.setSwiper();
}
setSwiper() {
const swiperEl = document.querySelector('.index5') as any;
const options: SwiperOptions = {
speed: 3000,
autoplay: {
delay: 5000,
},
allowTouchMove: false,
touchRatio: 0,
loop: true,
slidesPerView: document.documentElement.clientWidth >= 1440 ? 3 : 1,
spaceBetween: document.documentElement.clientWidth >= 1440 ? 88 : 0,
direction: 'horizontal',
};
Object.assign(swiperEl, options);
swiperEl.initialize();
}
@HostListener('window:resize', ['$event'])
onResize(event: any) {
this.setSwiper();
}
}
2. 컴포넌트
3. 무료이미지 가져오기
4. 뒤에 사이즈 입력하면 맞는 사이즈 이미지를 랜덤으로 가져올 수 있습니다.
<!-- slide -->
<div class="section4">
<div class="swiper-wrapper z-10">
<div *ngFor="let video of videos" class="swiper-slide">
<img [src]="video.image" />
</div>
</div>
</div>
5. div 만 사용하셔도 됩니다.
반응형
LIST
'IT' 카테고리의 다른 글
CURL 명령어 : Client URL 줄임말 (0) | 2023.06.30 |
---|---|
ApexChart 범위 0~100, 100~200 방식으로 보여주기 예시 / yaxis (0) | 2023.06.30 |
Tailwind hover 호버 시 커짐, 확대 효과 / force element state (0) | 2023.06.30 |
Angular 현재 URL 가져오기 router.events.pipe (0) | 2023.06.29 |
Angulr Swiper 배경 이미지 슬라이드 활용 예시 / 슬라이드 터치 막기, 시간, 반복, 상세 설정 (0) | 2023.06.29 |