Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swiper-react-component

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swiper-react-component

swiper-react-component,swiper ==========

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

swiper-react-component,swiper

description

基于支持useState,useRef,useEffect等hooks的react版本的轮播组件,有左右和上下轮播方向。

支持左右点击箭头切换,也可以点击下方指示器切换。

支持鼠标左键点击item项后滑动切换。支持鼠标滚动切换。

具体配置、事件、插槽可看下方详细文档

组件使用

  import { useState } from 'react'
  import SwiperReact from 'swiper-react-component'

  function App() {

    const list = [
      {
        id: 1,
        title: 'title1',
        content: 'content1'
      },
      {
        id: 2,
        title: 'title2',
        content: 'content2'
      },
      {
        id: 3,
        title: 'title3',
        content: 'content3'
      }
    ]
    
    return (
      <>
      <SwiperReact height={300} width={600} delay={ 3000 } mouseScroll>
        {
          list.map(item=>{
            return <div key={ item.id } style={{ height: "100%",width: "100%",background: "#99A9BF",display: 'flex',alignItems: 'center',justifyContent:"center"}}>
              { item.content }
            </div>
          })
        }
      </SwiperReact>
      </>
    )
}

export default App

Properties

propertytypedefaultdescription
directionStringhorizontal当前轮播的方向,默认为horizontal水平,vertical为垂直
autoplayBooleantrue是否自动播放轮播
delayNumber3000自动播放间隔,单位毫秒,默认3秒
indicatorBooleantrue是否显示轮播底部指示器
mouseSliderBooleanfalse是否开启鼠标点击轮播项左右滑动切换
triggerMoveNumbernull鼠标点击轮播项左右滑动切换的触发值,默认为滑动该容器1/2.5宽度或者高度切换
mouseScrollBooleanfalse是否开启鼠标滚轮切换轮播,默认不开启
hoverStopBooleantrue鼠标悬停时暂停轮播,默认为true
arrowStringalways左右切换箭头的显示形式,默认一直显示,值为always、hover、none
heightNumber200轮播容器高度
widthNumbernull轮播容器宽度,默认为容器父元素宽度
preArrowComponentReactNodenull自定义左箭头组件
nextArrowComponentReactNodenull自定义右箭头组件

swiper Event

namedescription
onChange轮播切换后触发事件,function(index: number){}

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc