Как добавить предыдущую и следующую функцию на вертикальной карусели? - PullRequest
0 голосов
/ 13 апреля 2020

Как добавить предыдущую и следующую функцию на вертикальную карусель, которая также совместима с Squarespace? Я пытаюсь смоделировать карусель по следующему коду, который я нашел из codepen

Когда я добавляю больше изображений в карусель, я не могу прокрутить вниз. Может кто-нибудь помочь показать мне, как я могу добавить эту функцию, пожалуйста? Заранее спасибо!

Ниже приведен код:

HTML

<div class="wrapper">
    <ul class="list-reset">
        <li class="active">
            <span>26 JAN</span>
            <a>Great win for the club</a>
            <img src="https://images.unsplash.com/photo-1420316078344-6149cb82b2c7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1650&q=80"
                 alt="">
        </li>
        <li>
            <span>22 JAN</span>
            <a>Can they be caught?</a>
            <img src="https://images.unsplash.com/photo-1517466787929-bc90951d0974?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
                 alt="">
        </li>
        <li>
            <span>17 JAN</span>
            <a>League is nearly over</a>
            <img src="https://images.unsplash.com/photo-1501386761578-eac5c94b800a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
                 alt="">
        </li>
        <li class="active">
            <span>26 JAN</span>
            <a>Great win for the club</a>
            <img src="https://images.unsplash.com/photo-1420316078344-6149cb82b2c7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1650&q=80"
                 alt="">
        </li>
        <li>
            <span>22 JAN</span>
            <a>Can they be caught?</a>
            <img src="https://images.unsplash.com/photo-1517466787929-bc90951d0974?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
                 alt="">
        </li>
        <li>
            <span>17 JAN</span>
            <a>League is nearly over</a>
            <img src="https://images.unsplash.com/photo-1501386761578-eac5c94b800a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
                 alt="">
        </li>
        <li class="active">
            <span>26 JAN</span>
            <a>Great win for the club</a>
            <img src="https://images.unsplash.com/photo-1420316078344-6149cb82b2c7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1650&q=80"
                 alt="">
        </li>
        <li>
            <span>22 JAN</span>
            <a>Can they be caught?</a>
            <img src="https://images.unsplash.com/photo-1517466787929-bc90951d0974?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
                 alt="">
        </li>
        <li>
            <span>17 JAN</span>
            <a>League is nearly over</a>
            <img src="https://images.unsplash.com/photo-1501386761578-eac5c94b800a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
                 alt="">
        </li>
    </ul>
    <div class="featured-image"></div>
</div>

CSS

body {
    background: #f3f3f3;
    color: #111;
    padding: 20px;
    display: flex;
    place-items: center;
    height: 100%;
    justify-content: center;
    align-items: center;
    height: 90vh;
}

.wrapper {
    width: 80%;
    position: relative;
    max-width: 100%;
    overflow: hidden;
    // border-radius: 3px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .1)
}

.list-reset {
    list-style-type: none;
    margin: 0;
    padding: 0;
    display: flex;
    width: calc(30% - 4px);
    min-height: 350px;
    height: 70vh;
    flex-direction: column;
    border: 2px solid #fff;
    li {
        padding: 20px;
        border-bottom: 2px solid #fff;
        transition: all 600ms ease;
        cursor: pointer;
        &:hover {
            background: #f9f9f9;
        }
        img {
            transition: all 600ms ease;
            opacity: 0;
            transform: translatey(10px);
            transform-origin: bottom;
        }
        a {
            display: block;
            margin-top: 4px;
        }
        span {
            font-size: 0.7rem;
            opacity: 0.7;
        }
        img {
            position: absolute;
            top: 0;
            right: 0;
            width: 70%;
            height: 100%;
            object-fit: cover;
            object-position: center;
        }
    }
    .active {
        z-index: 999;
        background: #fff;
        a {
            color: #548AF7;
        }
        img {
            opacity: 1;
            transform: translatey(0);
        }
    }
}

Javascript

$('.list-reset li').on('click', function() {
    $('.list-reset li').removeClass('active')
    $(this).addClass('active')
})
...