Я работал над этой драгбейной/прокручиваемой бесконечной каруселью в течение нескольких часов, но я столкнулся с проблемой. Кажется, что всякий раз, когда мои операторы IF попадают в InfinitesCroll , а пользовательские прокрутки «слишком быстро», оператор IF снова запускает перед Carousel.scrollleft () обновляется, вызывая карусель. В инструментах разработчика, но прокрутка в карусели должна работать при смене и прокрутке.
Я работал над этой драгбейной/прокручиваемой бесконечной каруселью в течение нескольких часов, но я столкнулся с проблемой. Кажется, что всякий раз, когда мои операторы IF попадают в InfinitesCroll , а пользовательские прокрутки «слишком быстро», оператор IF снова запускает перед Carousel.scrollleft () обновляется, вызывая карусель. В инструментах разработчика, но прокрутка в карусели должна работать при смене и прокрутке.[code]const carousel = $('.carousel'); const carouselCards = carousel.children('.card');
let cardAmount = 3; // The amount of cards visible within the carousel
carouselCards.slice(-cardAmount).get().reverse().forEach((e) => { let card = $(e); carousel.prepend(card.prop('outerHTML')); // Puts the last three cards in front of the first card in reverse order })
carouselCards.slice(0, cardAmount).get().forEach((e) => { let card = $(e); carousel.append(card.prop('outerHTML')); // Puts the first three cards after the last card })
let scrollTriggerStart = carouselCards.outerWidth() + carouselCards.outerWidth() / 2 - carousel.outerWidth() / 2; // The exact scrollLeft value where the second card is in the center of the carousel let scrollTriggerEnd = carousel[0].scrollWidth - carouselCards.outerWidth() - carouselCards.outerWidth() / 2 - carousel.outerWidth() / 2; // The exact scrollLeft value where the second to last card is in the center of the carousel let seamlessPosStart = carouselCards.length * carouselCards.outerWidth() - carouselCards.outerWidth() / 2 - carousel.outerWidth() / 2; // The exact scrollLeft value of the corresponding card of the second to last card let seamlessPosEnd = carousel[0].scrollWidth - carouselCards.length * carouselCards.outerWidth() + carouselCards.outerWidth() / 2 - carousel.outerWidth() / 2; // The exact scrollLeft value of the corresponding card of the second card