How to stop an event ongoing ?

Hello everybody, I try to make my own strip (3 “slides”) with Corvid. It is going well, it plays by itself slide to slide, but when I click on previous or next arrow to swtich slide, the function that make the ‘slides’ auto run, double infinitly. If any of you guys know a solution that allow me to stop the function in midway (and can help me to optimise the code), I would love to hear it. I tried for 5 hours on google and corvid forum and didntt find anything that work properly.

Thank you very very much!

Here is my code :

// Slide Option -------------------------------------------------------------------

let fadeOptions = {
“duration” : 250 ,
“delay” : 0
};

$w.onReady( function () {
//slide 1 to 2
$w( ‘#slide1’ ).onViewportEnter( () => {
setTimeout( function () {
$w( “#slide1” ).collapse(); }, 4000 );
setTimeout( function () {
$w( “#slide2” ).expand(); }, 4000 );
})

//slide 2 to 3
$w( ‘#slide2’ ).onViewportEnter( () => {
setTimeout( function () {
$w( “#slide2” ).collapse(); }, 4000 );
setTimeout( function () {
$w( “#slide3” ).expand(); }, 4000 );
})

//slide 3 to 1
$w( ‘#slide3’ ).onViewportEnter( () => {
setTimeout( function () {
$w( “#slide3” ).collapse(); }, 4000 );
setTimeout( function () {
$w( “#slide1” ).expand(); }, 4000 );
})

// Slide’s Buttons-------------------------------------------------------------------

//slide1 going to slide3
$w( ‘#arrowleft1’ ).onClick( () => {
$w( “#slide1” ).collapse()
$w( “#slide3” ).expand()
})

//slide1 going to slide2
$w( ‘#arrowright1’ ).onClick( () => {
$w( “#slide1” ).collapse()
$w( “#slide2” ).expand()
$w( “#slide3” ).collapse();
})

//slide2 going to slide1
$w( ‘#arrowleft2’ ).onClick( () => {
$w( “#slide2” ).collapse();
$w( “#slide1” ).expand();
$w( “#slide3” ).collapse();
});
//slide2 going to slide3
$w( ‘#arrowright2’ ).onClick( () => {
$w( “#slide2” ).collapse();
$w( “#slide3” ).expand();
$w( “#slide1” ).collapse();
})
//slide3 going to slide2
$w( ‘#arrowleft3’ ).onClick( () => {
$w( “#slide3” ).collapse();
$w( “#slide2” ).expand();
$w( “#slide1” ).collapse();
})
//slide3 going to slide1
$w( ‘#arrowright3’ ).onClick( () => {
$w( “#slide3” ).collapse();
$w( “#slide1” ).expand();
$w( “#slide2” ).collapse();
})
});

is it possible to stop an event ongoing ?

If you are using a slideshow, have you simply checked the settings in the editor to make sure that any navigation options are turned off etc as it looks like you are wanting to control it all by the use of code.
https://support.wix.com/en/the-wix-editor/slideshows

You can also use additional code to check if the slideshow is playing and then to stop it or move to another slide as you have done in your code.
https://www.wix.com/corvid/reference/$w.Slideshow.html
https://www.wix.com/corvid/reference/$w.Slide.html

https://www.wix.com/corvid/reference/$w.Slideshow.html#isPlaying
isPlaying
Indicates if the element is currently playing.

Description
To set the isPlaying property on an element, use the element’s play() and pause() functions.

If you select Autoplays on loading in the element’s Settings panel in the Editor, the isPlaying property is set to true when the page loads.

Thank you for the answer, very appreciate.
Actually, I am doing a slide on EditorX. I didn’t see any slide available. I think it is because it’s still a beta version.
So I’m making it with containers and code.

Yes makes a difference using Editor X as it is not fully open with all of the things that you currently have in the Wix Editor.

The only option you have here for the time being is to use a gallery and setup your slides as images and code the gallery to move back and forth etc.

However, if you are happy with containers and code, then stick with what you are doing.