Skip to content

feat(carousel): add no-hover-pause prop #2888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/carousel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ carousel, set the `interval` back to the desired number of ms.
When the carousel is paused, the user can still switch slides via the controls (if enabled) or touch
swipe (on touch enabled devices, if not disabled).

When the users mouse hovers the carousel it will automatically pause, and will automatically
restart when the mouse leaves the carousel. To disable this feature, set the `no-hover-pause`
prop on <b-carousel>`.

## Controls and Indicators

Set the prop `controls` to enable the previous and next control buttons.
Expand Down
11 changes: 9 additions & 2 deletions src/components/carousel/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ function getTransisionEndEvent(el) {
return null
}

const noop = () => {}

// @vue/component
export default {
name: 'BCarousel',
Expand Down Expand Up @@ -112,6 +114,11 @@ export default {
type: Boolean,
default: false
},
noHoverPause: {
// Disable pause on hover
type: Boolean,
default: false
},
imgWidth: {
// Sniffed by carousel-slide
type: [Number, String]
Expand Down Expand Up @@ -541,8 +548,8 @@ export default {
)

const on = {
mouseenter: this.pause,
mouseleave: this.restart,
mouseenter: this.noHoverPause ? noop : this.pause,
mouseleave: this.noHoverPause ? noop : this.restart,
focusin: this.pause,
focusout: this.restart,
keydown: evt => {
Expand Down