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

react-native-simple-slideshow

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-simple-slideshow

A quick and easy slideshow for react native.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-simple-slideshow

A quick and easy slideshow for react native. (Android & iOS)

GIF GIF

Installation

yarn add react-native-simple-slideshow

Usage

import Slideshow from 'react-native-simple-slideshow';

// ...

render() {
  return (
    <Slideshow
      dataSource={[
        { url:'http://placeimg.com/640/480/any' },
        { url:'http://placeimg.com/640/480/any' },
        { url:'http://placeimg.com/640/480/any' }
    ]}/>
  );
}

Autoplay Example

export default class SlideshowTest extends Component {
  constructor(props) {
    super(props);

    this.state = {
      position: 1,
      interval: null,
      dataSource: [
        {
          title: 'Title 1',
          caption: 'Caption 1',
          url: 'http://placeimg.com/640/480/any',
        }, {
          title: 'Title 2',
          caption: 'Caption 2',
          url: 'http://placeimg.com/640/480/any',
        }, {
          title: 'Title 3',
          caption: 'Caption 3',
          url: 'http://placeimg.com/640/480/any',
        },
      ],
    };
  }

  componentWillMount() {
    this.setState({
      interval: setInterval(() => {
        this.setState({
          position: this.state.position === this.state.dataSource.length ? 0 : this.state.position + 1
        });
      }, 2000)
    });
  }

  componentWillUnmount() {
    clearInterval(this.state.interval);
  }

  render() {
    return (
    <Slideshow
        dataSource={this.state.dataSource}
        position={this.state.position}
        onPositionChanged={position => this.setState({ position })} />
    );
  }
}

Props

PropertyTypeisRequired?DefaultDescription
dataSourceboolrequired-slideshow data
heightnumberoptional200container height
positionnumberoptional-set position slideshow
scrollEnabledbooloptionaltrueenable / disable scrolling
overlaybooloptionalfalsebackground overlay
indicatorSizenumberoptional16indicator size
indicatorColorstringoptional#CCCCCCindicator color
indicatorSelectedColorstringoptional#FFFFFFindicator selected color
arrowSizenumberoptional16arrow size
arrowLeftobjectoptional-component arrow left
arrowRightobjectoptional-component arrow right
onPressfuncoptional-returns an object image and index of image pressed
onPositionChangedfuncoptional-called when the current position is changed
containerStyleobjectoptional-custom styles for container

Data Structure

// example data structure

dataSource: [
  {
    title: 'title 1',
    caption: 'caption 1',
    url: 'url 1',
  }, {
    title: 'title 1',
    caption: 'caption 1',
    url: 'url 2',
  },
]
PropertyTypeDescription
titlestringtitle
captionstringcaption
urlstring / numberimage (URL or a local file resource)

Credits

Originally created by @haqiqi, modified by @dudynskyi.

License

MIT

Keywords

FAQs

Package last updated on 27 Jan 2019

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