1.0.1 • Published 4 years ago

multitypeslider v1.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

React MultiTypeSlider by Taha Khozooie

a multi type media support slider for react app

NPM JavaScript Style Guide

Contact me for support more types ;)

Install

npm install --save multitypeslider

Usage

import {MultiTypeSlider} from 'multitypeslider'
import 'multitypeslider/dist/index.css'
import TestVideo from './videotest.mp4'

const App = () => {

  const data = [
    {
      src: "https://miro.medium.com/max/5548/1*lK8DqxRW7pYqaZnZHJDDfw.png", // LocalImage OR URL
      type: "image", // REQUIRED <<<<<
      alt: "alt for img tag"
    },
    {
      src: TestVideo, // LocalVideo OR URL
      type: "video", // REQUIRED <<<<<
      thumb: "https://miro.medium.com/max/5548/1*lK8DqxRW7pYqaZnZHJDDfw.png" // LocalImage OR URL
    }
  ];

  return <MultiTypeSlider
    DataList={data}
    Width="100%"
    ShowList={true}
    Loop={true}
    AutoSwipe={true}
    Interval={3000}
    EnableListItemActionButton={true}
    EnableSliderButtons={true}
    onPressListItemActionButton={si => {
      console.log(si)
    }}
    onPressNextSlide={ns => {
      console.log(ns)
    }}
    onPressPrevSlide={ps => {
      console.log(ps)
    }}
    EnableVideoPlayerController={true}
    ListItemActionButton={<div style={{width: 10, height: 10, backgroundColor: 'green'}}/>}
    NextSlideButton={<div style={{width: 10, height: 10, backgroundColor: 'red'}}/>}
    PrevSlideButton={<div style={{width: 10, height: 10, backgroundColor: 'blue'}}/>}
  />

};

Props

PropDescriptionRequiredType
DataListThe list of data that you want to shownYesArray
WidthWidth of parent (default is 100%)NoString
ShowListShow list items below sliderNoBoolean
LoopRestart slider from first itemNoBoolean
AutoSwipeAuto swipe to next slideNoBoolean
IntervalAuto swipe interval time in millisecond (default is 4000)NoNumber
EnableListItemActionButtonShow a button on the small images below slider (ShowList Prop)NoBoolean
EnableSliderButtonsShow Next & Prev buttonsNoBoolean
onPressListItemActionButtonIf EnableListItemActionButton, this prop returns clicked item objectNoObject
onPressNextSlideThis prop returns next slide item objectNoObject
onPressPrevSlideThis prop returns previous slide item objectNoObject
EnableVideoPlayerControllerThis prop change video player controllers visibility (default is false)NoBoolean
ListItemActionButtonThis prop given component that you want shown as icon for button on the small images below sliderNoComponent
NextSlideButtonThis prop given component that you want shown as icon for slider next buttonNoComponent
PrevSlideButtonThis prop given component that you want shown as icon for slider previous buttonNoComponent

License

MIT © tahakhozooie