57

Is it possible to prevent the Bootstrap carousel pause on mouse hover behaviour and continue automatically cycling through the items instead?

The documentation only mentions the default behaviour of pause: "hover", if I change the pause argument to anything else then the carousel stops working altogether so I'm not sure how to disable this default behaviour.

Andy Bowskill
  • 1,734
  • 3
  • 18
  • 36

9 Answers9

94

I've found that a value of "false" will cause the carousel to keep cycling during a mouseover:

$('.carousel').carousel({
    pause: "false"
});

I am using Twitter Bootstrap v2.0.2

xcer
  • 1,697
  • 2
  • 16
  • 18
65

You can add this to the div .carousel too instead of using javascript.

Add delay time:

data-interval="3000"

Add if it pauses on hover or not, options are true and false

data-pause="false"

Example would be:

<div id="carousel" class="carousel" data-ride="carousel" data-interval="3000" data-pause="false">

This worked for me.

JCBrown
  • 1,062
  • 10
  • 11
7
$('.carousel').carousel({
        pause: 'none'
    })

for Bootstrap v3.3.4

wpdevramki
  • 171
  • 1
  • 2
5

for Bootstrap v5.1

data-bs-pause="false"

Eg: <div class="carousel slide" data-bs-ride="carousel" data-bs-pause="false">

Amirshad
  • 101
  • 2
  • 2
2

Bootstrap 4 Remove Pause on hover

$('.carousel').carousel({
    interval: 2000,
    cycle: true,
    pause: "null"
})
Ulysse BN
  • 10,116
  • 7
  • 54
  • 82
2

For anyone still visiting this thread, in the most recent version of 4.1.3, use null without quotations. Maybe quotes were required in previous v.4 versions, but not the case now:

$('.carousel').carousel({
    interval: 2000,
    cycle: true,
    pause: null
})
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
2

In Bootstrap 4 :

data-pause="false"

Eg: <div class="carousel slide" id="carousel" data-pause="false" data-ride="carousel">

This setting prevents the pause.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
Bijeesh
  • 21
  • 2
0

I have found that there are 2 things on which this cycling and pausing depends.

  1. When mouse enters (mouseenter - pause sliding)
  2. When mouse leaves (mouseleave - resume sliding)

Just change following line of code in your js/bootstrap.js file to allow continuous sliding.

.on('mouseenter', $.proxy(this.pause, this)) to

.on('mouseenter', $.proxy(this.**cycle**, this))

  • Editing source files is a terrible idea. All your changes will be lost if you choose to upgrade. Also a lot of developers choose to use external hosted files (e.g. those hosted on bootstrapcdn.com) and can't even be changed. Moreover, when you change a source file for your entire website, you might get unexpected results on other pages. – JerkMan Nov 08 '18 at 11:45
0

Utilize data attributes and append the option name to data-bs-. For this case, it should be data-bs-pause="false".

Erick
  • 1
  • 1