slider - pause on hover

4 replies · opened Apr 18, 2024

Bbrano099Apr 18, 2024

Hi,
I have a standard slider with autoplay and loop on my page and I would like it to stop when I mouse over it. how can I do that?
Thank you

SSemicolon WebSTAFFApr 26, 2024

Hello,

This is not available out of the box. So, you will need to customize this manually based on the example below:
[ch_pre type="js"]var mediaEl = document.querySelector('#videoEl');

mediaEl.onmouseover = function(){
if ( !mediaEl.paused ) {
mediaEl.pause();
}
};

mediaEl.onmouseout = function(){
if ( mediaEl.paused ) {
mediaEl.play();
}
};[/ch_pre]

This should work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Bbrano099May 2, 2024

I guess I'm stupid :) I have a slider with id="slider" and when I add your script to the web and replace in querySelector('#videoEl'); with querySelector('#slider'); it doesn't work and the slider is still running even when mouse is over slide

SSemicolon WebSTAFFMay 16, 2024

Hello,

Apologies for the Misunderstandings.

We had provided you with the codes for Pausing the Video on Hover. Simply add the data-hover="true" Attribute on the #slider Element.

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Bbrano099May 20, 2024

Thank you

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard