3d-react-carousal 中文文档教程

发布于 3年前 浏览 27 项目主页 更新于 3年前

React 3D Carousel component

反应中的 3D 旋转木马组件(支持滑动)。

Demo

Demo

jsfiddle (https://jsfiddle.net/suhailsulu/8hnqaz2c/)

Installation

npm

 npm i 3d-react-carousal

yarn

 yarn add 3d-react-carousal
Add fa-css in public.html for arrows
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
Importing the component
import {Carousel} from '3d-react-carousal';
.
.
.
let slides = [
    <img  src="https://picsum.photos/800/300/?random" alt="1" />,
    <img  src="https://picsum.photos/800/301/?random" alt="2" />  ,
    <img  src="https://picsum.photos/800/302/?random" alt="3" />  ,
    <img  src="https://picsum.photos/800/303/?random" alt="4" />  ,
    <img src="https://picsum.photos/800/304/?random" alt="5" />   ];
.
.
.
.
const callback = function(index){
    console.log("callback",index);
}
.
.
<Carousel slides={slides} autoplay={true} interval={1000} onSlideChange={callback}/>

props

幻灯片:-反应组件数组
自动播放:- 布尔值(true 或 false)- 可选
interval :- 数字(以毫秒为单位的时间)- 可选
arrows :- 布尔值(true 或 false)- 可选
onSlideChange :- 以幻灯片索引作为参数的回调函数 - 可选
您可以在幻灯片中提供任何组件,例如图像、div 甚至您的自定义组件

React 3D Carousel component

3D carousel component in react (with swipe support).

Demo

Demo

jsfiddle (https://jsfiddle.net/suhailsulu/8hnqaz2c/)

Installation

npm

 npm i 3d-react-carousal

yarn

 yarn add 3d-react-carousal
Add fa-css in public.html for arrows
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
Importing the component
import {Carousel} from '3d-react-carousal';
.
.
.
let slides = [
    <img  src="https://picsum.photos/800/300/?random" alt="1" />,
    <img  src="https://picsum.photos/800/301/?random" alt="2" />  ,
    <img  src="https://picsum.photos/800/302/?random" alt="3" />  ,
    <img  src="https://picsum.photos/800/303/?random" alt="4" />  ,
    <img src="https://picsum.photos/800/304/?random" alt="5" />   ];
.
.
.
.
const callback = function(index){
    console.log("callback",index);
}
.
.
<Carousel slides={slides} autoplay={true} interval={1000} onSlideChange={callback}/>

props

slides :- Array of react components
autoplay :- Boolean (true or false) - optional
interval :- number (time in milliseconds) - optional
arrows :- Boolean (true or false) - optional
onSlideChange :- callback function with index of the slide as argument - optional
You can give any component in the slides like images, divs or even your custom components

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文