Pause for Custom Carousel

Avatar

Avatar

sunitac70336244

Avatar

sunitac70336244

sunitac70336244

05-02-2019

Dear All,

We need a pause button in our custom carousel , which is migrated from AEM 5.6 to AEM 6.4.

The new requirement is , if somebody will click on pause button then the carousel slide will pause and  again they will click on same pause button then the the slide will again play with time interval 3 seconds...

In the below code , i have written the pause functionality...But It is not working , as expected.

<sly data-sly-use.carousel = "com.trp.wtc.sunita.pojo.LandingPosterCarouselTest"/>

<div>Landing Page Carousel Testing Here</div>

<div id="myCarousel" class="carousel-eb carousel slide" data-ride="carousel" data-interval="3000">

<sly data-sly-test="${carousel.slidesList}">

<div class="carousel-inner ${properties.addPadding ? 'carousel-inner-eb' : ''}" role="listbox">

<sly data-sly-list="${carousel.slidesList}">

<div class="item ${item.count == '0' ? 'active' : ''}">

<sly data-sly-test="${item.bgImage}">

<img src="${item.bgImage}" style="width:100%" alt="">

<div class="overlay"></div>

</sly>

</div>

</sly>

</div>

</sly>

<sly data-sly-test.slide="${carousel.slidesList}">

<sly data-sly-test="${slide.size > 1}">

<a id="left" class="left carousel-control ${properties.addPadding?'':'carousel-control-np'} left-arrow ${item.count}" href="#myCarousel" data-slide="prev" >

<em class="fa fa-angle-left"></em>

</a>

<a id="right" class="right carousel-control ${properties.addPadding? '' :'carousel-control-np'} right-arrow" href="#myCarousel" data-slide="next" >

<em class="fa fa-angle-right"></em>

</a>

<div class="${properties.addPadding? '' : 'indicator-eb' }">

<ol class="carousel-indicators">

<sly data-sly-list="${carousel.slidesList}">

<li data-target="#myCarousel" data-slide-to="${item.count}" class="${item.count == '0' ? 'active' : ''}"></li>

</sly>

<button class="controls" id="pause">Pause</button>

</ol>

</div>

</sly>

</sly>

</div>

<script>

   var slides = document.querySelectorAll('#slides .myCarousel');

var currentSlide = 0;

var slideInterval = setInterval(nextSlide,3000);

function nextSlide(){

slides[currentSlide].className = 'myCarousel';

currentSlide = (currentSlide+1)%slides.length;

slides[currentSlide].className = 'item1 active';

}

var playing = true;

var pauseButton = document.getElementById('pause');

function pauseSlideshow(){

pauseButton.innerHTML = 'Play';

playing = false;

clearInterval(slideInterval);

}

function playSlideshow(){

pauseButton.innerHTML = 'Pause';

playing = true;

slideInterval = setInterval(nextSlide,3000);

}

pauseButton.onclick = function(){

if(playing){ pauseSlideshow(); }

else{ playSlideshow(); }

};

</script>

My website page is coming like below.

1684891_pastedImage_6.png

But when I click on Pause button then it is not working as expected. Can you please help me on this.

View Entire Topic

Avatar

Avatar

sunitac70336244

Avatar

sunitac70336244

sunitac70336244

05-02-2019

Hi Donald, For new functionality we are using the core aem... But this carousel is migrated from 5.6 to 6.4.... Can you please let us know how can we use the core AEM in the existing custom OLD code ? Do you have any example... The example provided by you is the new carousel development/ootb carousel...