티스토리 뷰

Development/.etc

react swiper autoplay 안될 때

쥬리리리 2023. 6. 11. 21:34

 

import SwiperCore, { EffectCoverflow, Pagination, Autoplay } from "swiper";

function content() {
SwiperCore.use([Autoplay]);
    return (
    <div className="mainContainer">
        <div id="content">
            <Swiper effect={"coverflow"} grabCursor={false} centeredSlides={true} 
            		slidesPerView={"auto"} loop={true} autoplay={{ delay: 2000, disableOnInteraction: false }}
                    coverflowEffect={{
                      rotate: 50,
                      stretch: 0,
                      depth: 100,
                      modifier: 1,
                      slideShadows: true,
                    }}
                    pagination={true} modules={[Autoplay, EffectCoverflow, Pagination]}>
                  <SwiperSlide>
                    <img src="/images/09.jpg" />
                  </SwiperSlide>
                  <SwiperSlide>
                    <img src="/images/10.jpg" />
                  </SwiperSlide>
                  <SwiperSlide>
                    <img src="/images/11.jpg" />
                  </SwiperSlide>
                </Swiper>
            </div>
        </div>
    );
}

export default content;

Autoplay와 SwiperCore도 같이 import후, 

autoplay={{ delay: 2000, disableOnInteraction: false }} 자동재생 관련 옵션을 주면 된다.

 

delay : 시간설정

disableOnInteraction : 클릭하거나 이미지를 넘겼을 경우 자동재생 멈춤

 

'Development > .etc' 카테고리의 다른 글

[dbeaver] 전체 실행 단축키  (0) 2023.09.19
JPA 쿼리 로그 설정  (0) 2023.05.09
[Oracle]사용자 조회,생성,삭제  (0) 2022.04.22
[Oracle]scott계정 비밀번호 모를 때  (0) 2022.04.22
정규식 패턴 / 유효성검사  (0) 2022.04.14
댓글
링크
최근에 올라온 글
Total
Today
Yesterday