Last active
August 24, 2021 12:04
-
-
Save nathobson/5770850df9485542ee93a583ca23248e to your computer and use it in GitHub Desktop.
Swiper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Elements exit at the same speed | |
.info span { | |
opacity: 0; | |
transition: opacity 1s ease; | |
} | |
.info .right button { | |
opacity: 0; | |
transition: opacity 1s ease; | |
} | |
// Elements animate in with offset delays when the active class is added | |
.swiper-slide-active, | |
.swiper-slide-duplicate-active { | |
.info span { | |
transition: opacity 1s ease 0.5s; | |
opacity: 1; | |
} | |
.info .right button { | |
transition: opacity 1s ease 0.7s; | |
opacity: 1; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="swiper-slide"> | |
<div class="image" data-swiper-parallax="80%"> | |
<img | |
alt="{{ $feature['image_alt'] }}" | |
sizes="80vw" | |
data-src="{{ $feature['image_src'] }}" | |
data-srcset="{{ $feature['image_srcset'] }}" | |
src="{{ $feature['image_placeholder'] }}" | |
class="swiper-lazy" | |
/> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Swiper, Navigation, Lazy } from 'swiper' | |
Swiper.use([Navigation, Lazy]) | |
new Swiper('.buying-featured .swiper-container', { | |
slidesPerView: 1.1, | |
spaceBetween: 20, | |
loop: true, | |
parallax: true, | |
loopedSlides: 2, | |
threshold: 0, | |
watchSlidesProgress: true, | |
speed: 1000, | |
lazy: { | |
loadPrevNext: true, | |
loadOnTransitionStart: true, | |
}, | |
watchSlidesVisibility: true, | |
navigation: { | |
nextEl: '.buying-featured .swiper-button-next', | |
prevEl: '.buying-featured .swiper-button-prev', | |
}, | |
slideToClickedSlide: true, | |
breakpoints: { | |
850: { | |
slidesPerView: 1, | |
spaceBetween: 0, | |
threshold: 50, | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment