Map and motion

Swiper hero

A full-screen property slider with fade, parallax, a caption that plays in, thumbnails and a progress line. Made with Swiper.

Example

Built with Swiper (MIT license). It fades between slides, moves the picture slightly for a parallax feel, plays the caption in, and runs a progress line while it waits. The thumbnails and arrows below are connected to it.

For sale

Family house with garden

  • $485,000
  • 4 Beds
View property
For sale

Modern villa with pool

  • $2,800/mo
  • 4 Beds
View property
For sale

Bright two-bedroom apartment

  • $312,000
  • 4 Beds
View property
01 / 03
Family house$485,000
Modern villa$2,800/mo
Apartment$312,000

Setup

  1. Add Swiper's CSS and JavaScript from the CDN (already on index-swiper.html), then assets/js/swiper-init.min.js after it.
  2. Put data-swiper="hero" on the main .swiper. Point data-swiper-thumbs at the thumbnail slider.
  3. Arrows (.sw-prev, .sw-next) and the counter (data-sw-count) are found inside the nearest data-swiper-scope.
  4. On the live page the slider fills the screen, changes slide every 6.5 seconds and stops when the visitor prefers reduced motion. Here it is switched off with data-swiper-options='{"autoplay":false}'.

Classes and attributes

NamePurpose
.sw-heroWrapper. Dark background. Holds the slider, the bottom panel and the progress line.
.sw-hero-main + data-swiper="hero"The main Swiper. Fade effect, loop, parallax, keyboard, autoplay.
.sw-hero-slide, .sw-hero-img, .sw-hero-bodyOne slide: picture, then the caption. Add data-swiper-parallax-x="-8%" to the picture for the parallax.
.sw-hero-tag, -title, -address, -info, -price, -spec, -actionsCaption parts, in the order they play in.
.sw-hero-panelBottom bar with counter, arrows and thumbnails.
.sw-hero-thumbs, .sw-hero-thumbThe thumbnail slider. The active one lifts and gets a brass border. Hidden on tablets and phones.
.sw-hero-progressThin line that fills while the slide waits.
data-swiper-optionsJSON that overrides any Swiper option, for example {"speed":600}.