- The VueJS wrapper for Owl Carousel.
-
Owl Carousel is touch enabled jQuery plugin that lets you create a beautiful responsive carousel slider.
-
Extended from vue-owl-carousel
-
Added
rtl
prop, can be changed dynamically (the carousel will be re-instantiated in rtl mode and on the same slide location) -
Added
autoHeight
prop -
Due to a bug in the responsive mode, i've added a temporarily fix by allowing
items
prop to be changed dynamically (likertl
), so you can determine the breakpoints and pass corresponding items from your main project. -
Fixed
initialize
&initialized
not being fired up. -
Added a
events
prop that takes an array of the events you want to register instead of registering all library events.
<template>
<carousel :events="['initialized', 'changed']" @initialized="intial" @changed="changed">
//
</carousel>
<template />
<script>
import carousel from 'xx-vue-owl-carousel'
export default {
components: { carousel },
methods: {
intial(event) {
console.log('owl carousel initialized')
console.log('number of slides:', event.item.count)
console.log('active slide index:', event.item.index)
},
changed(event) {
//
},
},
}
</script></template
>
- removed passing
next
&prev
as named slots. instead passslideValue
prop and create your custom buttons outside the carousel:
<template>
<carousel :slideValue="slideController">
//
</carousel>
<button @click="slideController++">next</button>
<button @click="slideController--">prev</button>
</template>
<script>
import carousel from 'xx-vue-owl-carousel'
export default {
components: { carousel },
data() {
return {
slideController: 0,
}
},
}
</script>
-
changed
webpack
torollup
. -
(
v1.1.9
) Added a method to manually re-instantiate the carousel if needed:
<template>
<carousel ref="carousel">
//
</carousel>
</template>
<script>
export default {
methods: {
refreshCarousel() {
this.$refs.carousel.refresh()
},
},
}
</script>
npm i -s xx-vue-owl-carousel
or yarn add xx-vue-owl-carousel
<script>
import carousel from 'xx-vue-owl-carousel'
export default {
components: { carousel },
}
</script>
Basic Usage
<carousel>
<img src="https://placeimg.com/200/200/any?1" />
<img src="https://placeimg.com/200/200/any?2" />
<img src="https://placeimg.com/200/200/any?3" />
<img src="https://placeimg.com/200/200/any?4" />
</carousel>
Set options,
<carousel :autoplay="true" :nav="false">
//
</carousel>
Set events,
<carousel @changed="changed" @updated="updated">
//
</carousel>
Currently following options are available.
type : number
default : 3
The number of items you want to see on the screen.
type : number
default : 0
Margin-right (px) on item.
type : boolean
default : false
Infinity loop. Duplicate last and first items to get loop illusion.
Type: Boolean
Default: false
Center item. Works well with even an odd number of items.
Type: Boolean
Default: false
Show next/prev buttons.
Type: Boolean
Default: false
Autoplay.
Type: Number/Boolean
Default: false
Autoplay speed.
Type: Boolean
Default: true
Go backwards when the boundary has reached.
Type: Boolean
Default: true
Mouse drag enabled.
Type: Boolean
Default: true
Touch drag enabled.
Type: Boolean
Default: true
Stage pull to edge.
Type: Boolean
Default: false
Item pull to edge.
Type: Number
Default: 0
Padding left and right on stage (can see neighbours).
Type: Boolean
Default: false
Set non grid content. Try using width style on divs.
Type: Boolean
Default: false
Set non grid content. Try using height style on divs.
Type: Boolean
Default: true
Show dots navigation.
Type: Number
Default: 5000
Autoplay interval timeout.
Type: Boolean
Default: false
Pause on mouse hover.
Type: Object
Default: {}
Example : :responsive="{0:{items:1,nav:false},600:{items:3,nav:true}}"
Object containing responsive options. Can be set to false to remove responsive capabilities.