React + Owl Carousel
e.g. webpack
// ...
plugins: [
// other plugins,
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
],
//...you can use html script tag to inject jquery as well.
wrap your divs inside the OwlCarousel component
import React from 'react';
import OwlCarousel from 'react-owl-carousel';
import 'owl.carousel/dist/assets/owl.carousel.css';
import 'owl.carousel/dist/assets/owl.theme.default.css';
// ....
// className "owl-theme" is optional
;| Name | Descrption | | :-----------: | :----------------------------------------------------------------- | --- | | onInitialize | When the plugin initializes. | ' | | onInitialized | When the plugin has initialized. | | onResize | When the plugin gets resized. | | onResized | When the plugin has resized. | | onRefresh | When the internal state of the plugin needs update. | | onRefreshed | When the internal state of the plugin has updated. | | onDrag | When the dragging of an item is started. | | onDragged | When the dragging of an item has finished. | | onTranslate | When the translation of the stage starts. | | onTranslated | When the translation of the stage has finished. | | onChange | Parameter: property. When a property is going to change its value. | | onChanged | Parameter: property. When a property has changed its value. | | onLoadLazy | When lazy image loads. | | onLoadedLazy | When lazy image has loaded. | | onStopVideo | When video has unloaded. | | onPlayVideo | When video has loaded. |
next(speed) prev(speed) to(position, speed) create() destroy() play(timeout, speed) stop()| Name | Type | Default | Descrption |
|---|---|---|---|
| refreshClass | string | 'owl-refresh' | Class during refresh. |
| loadingClass | string | 'owl-loading' | Class during load. |
| loadedClass | string | 'owl-loaded' | Class after load. |
| rtlClass | string | 'owl-rtl' | Class for right to left mode. |
| dragClass | string | 'owl-drag' | Class for mouse drag mode. |
| grabClass | string | 'owl-grab' | Class during mouse drag. |
| stageClass | string | 'owl-stage' | Stage class. |
| stageOuterClass | string | 'owl-stage-outer' | Stage outer class. |
| navContainerClass | string | 'owl-nav' | Navigation container class. |
| navClass | [string] | ['owl-prev','owl-next'] | Navigation buttons classes. |
| controlsClass | string | 'owl-controls' | Controls container class - wrapper for navs and dots. |
| dotClass | string | 'owl-dot' | Dot Class. |
| dotsClass | string | 'owl-dots' | Dots container class. |
| autoHeightClass | string | 'owl-height' | Auto height class. |
| responsiveClass | string/bool | false | Optional helper class. Add '-' class to main element. Can be used to stylize content on given breakpoint. |
| Name | Type | Default | Descrption |
|---|---|---|---|
| items | number | 3 | The number of items you want to see on the screen. |
| margin | number | 0 | margin-right(px) on item. |
| loop | bool | false | Infinity loop. Duplicate last and first items to get loop illusion. |
| center | bool | false | Center item. Works well with even an odd number of items. |
| mouseDrag | bool | true | Mouse drag enabled. |
| touchDrag | bool | true | Touch drag enabled. |
| pullDrag | bool | true | Stage pull to edge. |
| freeDrag | bool | false | Item pull to edge. |
| stagePadding | number | 0 | Padding left and right on stage (can see neighbours). |
| merge | bool | false | Merge items. Looking for data-merge='{number}' inside item.. |
| mergeFit | bool | true | Fit merged items if screen is smaller than items value. |
| autoWidth | bool | false | Set non grid content. Try using width style on divs. |
| startPosition | number/string | 0 | Start position or URL Hash string like '#id'. |
| URLhashListener | bool | false | Listen to url hash changes. data-hash on items is required. |
| nav | bool | false | Show next/prev buttons. |
| rewind | bool | true | Go backwards when the boundary has reached. |
| navText | [dom element] | ['next','prev'] | HTML allowed. |
| navElement | string | 'div' | DOM element type for a single directional navigation link. |
| slideBy | number/string | 1 | Navigation slide by x. 'page' string can be set to slide by page. |
| dots | bool |
暂无开放 Issues,或尚未同步最近议题。