Запрос Uri : getQueryParams()
Тело запроса : getBody()
/ getParsedBody()
Это не совсем что вы ищете, но оно довольно близко.
Вы делаете очень хорошую работу ... щелчком .dot
вы можете начать с получения его индекса li
, а затем использовать индекс, чтобы показать / скрыть слайды
$(document).ready(function () {
$('.slide:eq(-1)').addClass('last');
$('.dot:first').addClass('active');
$('.slide:first').addClass('active').delay($duration).queue(function () {
$(this).addClass('show-text');
});
$('.slide:eq(1)').addClass('next');
});
var $classes = 'last active show-text next';
var $duration = 1250;
$('.dot').on('click' , function(){ // the dot click
var $This = $(this);
var GetIndex = $This.closest('li').index(); // get this li index
$('.dot').removeClass('active').filter($This).addClass('active'); // remove class active from other .dots and add the active class to the click one
alert(GetIndex);
});
$('.button').click(function moveSlide() {
var $active = $('.slide.active');
var $prevSlide = $('.slide').eq(($active.index() - 1) % $('.slide').length);
var $afterPrevSlide = $('.slide').eq(($active.index() - 2) % $('.slide').length);
var $nextSlide = $('.slide').eq(($active.index() + 1) % $('.slide').length);
var $slideAfterNext = $('.slide').eq(($active.index() + 2) % $('.slide').length);
var $tagNextDot = $('#' + $prevSlide.attr('id') + 'Dot' );
var $tagPrevDot = $('#' + $nextSlide.attr('id') + 'Dot' );
$active.dequeue();
$('.slide').removeClass($classes)
$('.dot').removeClass('active');
if ($(this).is("#prev")) {
$active.addClass('next');
$tagNextDot.addClass('active');
$prevSlide.addClass('active').delay($duration).queue(function () {
$(this).addClass('show-text');
});
$afterPrevSlide.addClass('last');
} else {
$active.addClass('last');
$tagPrevDot.addClass('active');
$nextSlide.addClass('active').delay($duration).queue(function () {
$(this).addClass('show-text');
});
$slideAfterNext.addClass('next');
}
});
body {
font-size: 16px;
font-family: 'Heebo', sans-serif;
text-transform: uppercase;
font-weight: 900;
}
/* Slides */
.slide-wrapper {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
overflow: hidden;
}
.slide {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 70%;
left: 140%;
z-index: 0;
transition: 1.25s;
box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
}
.slide h2 {
display: none;
color: #fff;
text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
letter-spacing: -2px;
font-size: 3rem;
}
.slide.active.show-text h2 {
display: block;
animation: reveal-text 1.5s forwards;
}
@keyframes reveal-text {
0% { opacity: 0; }
100% { opacity: 1; }
}
#slide1 {
background-image: radial-gradient(
rgba(0, 0, 0, 0.05),
rgba(0, 0, 0, 0.35)
), url('https://picsum.photos/1250/1600/?random');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
#slide2 {
background-image: radial-gradient(
rgba(0, 0, 0, 0.05),
rgba(0, 0, 0, 0.35)
), url('https://picsum.photos/1200/1600/?random');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
#slide3 {
background-image: radial-gradient(
rgba(0, 0, 0, 0.05),
rgba(0, 0, 0, 0.35)
), url('https://picsum.photos/1200/1500/?random');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
#slide4 {
background-image: radial-gradient(
rgba(0, 0, 0, 0.05),
rgba(0, 0, 0, 0.35)
), url('https://picsum.photos/1300/1600/?random');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.slide.last {
left: 0;
z-index: 0;
}
.slide.active {
left: 0;
z-index: 1;
}
.slide.next {
left: 70%;
z-index: 2;
}
.dots-wrapper {
z-index: 10;
list-style: none;
padding-left: 0;
position: absolute;
bottom: 0;
padding: 10px;
}
.dots-wrapper li {
display: inline;
}
.dot {
display: inline-block;
width: 8px;
height: 8px;
border: 2px solid #fff;
border-radius: 6px;
}
.dot.active {
background-color: red;
border-color: red;
}
/* Buttons */
.button-wrapper {
display: flex;
z-index: 10;
width: 100%;
justify-content: space-between;
align-items: center;
}
.button {
background-color: rgba(0,0,0,0.45);
color: #ddd;
height: 40px;
border: none;
font-weight: bold;
padding: 10px 20px;
transition: 0.3s;
}
.button:hover {
cursor: pointer;
background: rgba(0,0,0,0.85);
color: #fff;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="slide-wrapper">
<div id="slide1" class="slide">
<h2>Slide One.</h2>
</div>
<div id="slide2" class="slide">
<h2>Slide Two.</h2>
</div>
<div id="slide3" class="slide">
<h2>Slide Three.</h2>
</div>
<div id="slide4" class="slide">
<h2>Slide Four.</h2>
</div>
<div class="button-wrapper">
<button id="prev" class="button">Prev.</button>
<button id="next" class="button">Next.</button>
</div>
<ul class="dots-wrapper">
<li>
<span id="slide1Dot" class="dot"></span>
</li>
<li>
<span id="slide2Dot" class="dot"></span>
</li>
<li>
<span id="slide3Dot" class="dot"></span>
</li>
<li>
<span id="slide4Dot" class="dot"></span>
</li>
</ul>
</div>
Примечание: это не полный ответ, но объясняет идею использования индекса li
для получения количество нажатых .dot