百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-owl-carousel

> 编程语言
开源

React + Owl Carousel

198 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

React + Owl Carousel

react-owl-carousel

React + Owl Carousel 2.3

1. Getting Started

  • You need to inject a global window.jQuery first.

e.g. webpack

javascript
// ...
plugins: [
    // other plugins,
    new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery'
    }),
],
//...

you can use html script tag to inject jquery as well.

2. Set up your component

wrap your divs inside the OwlCarousel component

javascript
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

    

    

    

    

    

    

    

    

    

    

    

    

;

Event

| 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. |

OwlCarousel Method

  •   next(speed)
  •   prev(speed)
  •   to(position, speed)
  •   create()
  •   destroy()
  •   play(timeout, speed)
  •   stop()

OwlCarousel Class Props

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.

OwlCarousel Options

offical docs

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· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言