F
F
Fedor2019-02-27 19:37:35
JavaScript
Fedor, 2019-02-27 19:37:35

How to add the effect of the appearance of new and disappearance of old elements of the slider?

1. You need to set the slides to red when they appear 2. You need to set the slides
to blue when they disappear
https://codepen.io/FedorT/pen/wOapyy

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fedor, 2019-02-27
@Fedor19

I tried, in this case everything works. Thank you!
In general, I thought about something more universal, so that the number of active slides changes depending on the viewport, the slidesToShow parameter. For example, 10, 7, 4, 1. This is where the ambush comes in.

V
Vitaly Kirenkov, 2019-02-27
@DeLaVega

It seems to me that everything is quite simple here.

.non-active { background-color: blue; }
.active { background-color: red; }

On the onChange method, you find the active element, set the class (.active) on it, on .prev and on .next, and drop the class from all the rest

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question