A hero slideshow without a library
is what the slideshow code weighs compressed, without React
In short
In a website project for a renovation company, the effect on the first screen did not work on an iPhone. I replaced it with a photo slideshow that asks nothing of your finger. The slideshow code weighs about 1 KB compressed, with no slider library.
Krawędź is a made-up renovation company that I use to show what a website in this trade can look like. The demo is at remonty.tfagency.pl.
An effect that did not survive the iPhone
The first version had a paint roller. You dragged it over a photo of an old bathroom, and wherever it passed, the renovated bathroom appeared. It worked on a computer. On an iPhone you could only see the “before” photo, the roller at the side and a “Show after renovation” button.
I could have looked for the cause, but I asked a different question: should the first screen need dragging at all? Most people on a phone scroll the page rather than play with a photo. If the effect does not work, or someone does not notice it, they miss the most important thing the page has to show. So instead of fixing the roller, I changed the idea.
What is on the first screen now
- Four full-width photos that change on their own every 5 seconds with a smooth crossfade. The first one is a bathroom split in half: the left half before the renovation, the right half after.
- A slow zoom. The photo on screen zooms from 112% to 100% over 7 seconds, so the picture is always slightly alive.
- Bars to switch photos. Under the photos there are four short bars. The active one fills up at the pace of the slideshow, so you can see when the next photo is coming.
- The heading comes in step by step. First a short rule, then the title lines from below, and finally the text and buttons.
Why without a library
Ready-made sliders can do a lot: dragging, loops, several photos at once, 3D effects. Here I only need to change the photo every few seconds. Two things are enough for that:
- The number of the active photo, which goes up by one every 5 seconds and returns to the first after the last.
- A CSS crossfade. All the photos are stacked, and the active one gets a class that raises its opacity. A one-second
opacitytransition does the rest.
The whole component is 2.0 KB minified and about 1 KB compressed. I am not counting React, because the site uses it anyway.
When the slideshow stops
Movement on a page does not help everyone, so the slideshow stops when:
- someone holds the mouse cursor over the photos,
- someone moves through the page with a keyboard and is on one of the bars,
- someone has reduced motion turned on in their system. Then nothing moves on its own, and the photos change with the bars.
A bug the test caught
The heading sits on top of the photos, so its invisible box covered the bars. Everything looked fine, but the bars did not respond to touch. It only came out in an automated test that tried to tap the fourth bar on an emulated iPhone.
The fix is two lines: the text block lets touches through to what is underneath, and only the buttons inside it stay clickable.
.hero-tekst { pointer-events: none; }
.hero-tekst a { pointer-events: auto; }It is a good example of why I check websites with tests and not just by eye. In the screenshots everything looked right, and one element simply did not work.
What this means for your website
The best effect on the first screen is one that works on its own, without instructions and without touching. Interaction is better placed lower on the page, where it is an extra and not a condition for seeing the most important content. If your website has something at the top that has to be clicked or dragged, check it on your own phone. If something does not work, get in touch.