Skip to content

Commit

Permalink
Added demo with css-only horizontal sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Verlicchi committed Jan 12, 2022
1 parent e841594 commit 955473a
Show file tree
Hide file tree
Showing 2 changed files with 319 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ The [demos](https://github.com/verlok/vanilla-lazyload/tree/master/demos) folder
| Loading | Asynchronous loading LazyLoad with `<script async>` | [Code](demos/async.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/async.html) |
| Loading | Asynchronous loading multiple LazyLoad instances with `<script async>` | [Code](demos/async_multiple.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/async_multiple.html) |
| Technique | Fade in images as they load | [Code](demos/fade_in.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/fade_in.html) |
| Technique | Lazily create lazyload instances | [Code](demos/lazily_load_lazyLoad.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/lazily_load_lazyLoad.html) |
| Technique | Lazy load images in CSS-only horizontal sliders (Netflix style) | [Code](demos/sliders_css_only.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/sliders_css_only.html) |
| Technique | Lazily create Swiper instances and lazily load Swiper images | [Code](demos/swiper.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/swiper.html) |
| Technique | Lazily execute functions as specific elements enter the viewport | [Code](demos/lazy_functions.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/lazy_functions.html) |
| Technique | How to manage the print of a page with lazy images | [Code](demos/print.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/print.html) |
Expand Down
318 changes: 318 additions & 0 deletions demos/sliders_css_only.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
o<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>Swipey CSS only - Lazyload demos</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
ul,
li {
list-style-type: none;
margin: 0;
padding: 0;
}

a,
img {
display: block;
}

img {
border: 0;
width: 220px;
height: 280px;
}

img:not([src]) {
visibility: hidden;
}

.slider {
width: 100%;
height: 280px;
margin-bottom: 40px;
}

.slider-wrapper {
overflow-x: scroll;
scroll-snap-type: x mandatory;
scroll-snap-align: start;
display: flex;
gap: 20px;
}

.slider-slide {
width: 220px;
}

.slider-slide img {
display: block;
}
</style>
</head>

<body>
<h1>Swipey, CSS only</h1>
<p>First slider</p>
<div class="slider">
<div class="slider-wrapper">
<div class="slider-slide">
<img
alt="Stivaletti"
src="https://via.placeholder.com/220x280?text=S01E01"
srcset="https://via.placeholder.com/440x560?text=S01E01 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide">
<img
alt="Stivaletti"
src="https://via.placeholder.com/220x280?text=S01E02"
srcset="https://via.placeholder.com/440x560?text=S01E02 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S01E03"
data-srcset="https://via.placeholder.com/440x560?text=S01E03 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S01E04"
data-srcset="https://via.placeholder.com/440x560?text=S01E04 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S01E05"
data-srcset="https://via.placeholder.com/440x560?text=S01E05 2x"
width="220"
height="280"
/>
</div>
</div>
</div>

<p>Second slider</p>
<div class="slider">
<div class="slider-wrapper">
<div class="slider-slide">
<img
alt="Stivaletti"
src="https://via.placeholder.com/220x280?text=S02E01"
srcset="https://via.placeholder.com/440x560?text=S02E01 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide">
<img
alt="Stivaletti"
src="https://via.placeholder.com/220x280?text=S02E02"
srcset="https://via.placeholder.com/440x560?text=S02E02 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S02E03"
data-srcset="https://via.placeholder.com/440x560?text=S02E03 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S02E04"
data-srcset="https://via.placeholder.com/440x560?text=S02E04 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S02E05"
data-srcset="https://via.placeholder.com/440x560?text=S02E05 2x"
width="220"
height="280"
/>
</div>
</div>
</div>

<p>Another slider</p>
<div class="slider">
<div class="slider-wrapper">
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S03E01"
data-srcset="https://via.placeholder.com/440x560?text=S03E01 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S03E02"
data-srcset="https://via.placeholder.com/440x560?text=S03E02 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S03E03"
data-srcset="https://via.placeholder.com/440x560?text=S03E03 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S03E04"
data-srcset="https://via.placeholder.com/440x560?text=S03E04 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S03E05"
data-srcset="https://via.placeholder.com/440x560?text=S03E05 2x"
width="220"
height="280"
/>
</div>
</div>
</div>

<p>Yet another slider</p>
<div class="slider">
<div class="slider-wrapper">
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S04E01"
data-srcset="https://via.placeholder.com/440x560?text=S04E01 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S04E02"
data-srcset="https://via.placeholder.com/440x560?text=S04E02 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S04E03"
data-srcset="https://via.placeholder.com/440x560?text=S04E03 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S04E04"
data-srcset="https://via.placeholder.com/440x560?text=S04E04 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S04E05"
data-srcset="https://via.placeholder.com/440x560?text=S04E05 2x"
width="220"
height="280"
/>
</div>
</div>
</div>

<p>And yet another yet another slider</p>
<div class="slider">
<div class="slider-wrapper">
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S05E01"
data-srcset="https://via.placeholder.com/440x560?text=S05E01 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S05E02"
data-srcset="https://via.placeholder.com/440x560?text=S05E02 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S05E03"
data-srcset="https://via.placeholder.com/440x560?text=S05E03 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S05E04"
data-srcset="https://via.placeholder.com/440x560?text=S05E04 2x"
width="220"
height="280"
/>
</div>
<div class="slider-slide slider-slide--lazy">
<img
alt="Stivaletti"
data-src="https://via.placeholder.com/220x280?text=S05E05"
data-srcset="https://via.placeholder.com/440x560?text=S05E05 2x"
width="220"
height="280"
/>
</div>
</div>
</div>

<script src="../dist/lazyload.min.js"></script>
<script>
const lazysliders = new LazyLoad({
elements_selector: ".slider-slide--lazy img"
});
</script>
</body>
</html>

0 comments on commit 955473a

Please sign in to comment.