• Stars
    star
    237
  • Rank 169,885 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A quick and easy image slider for react native. Maintainer wanted!

react-native-image-slider

A quick and easy image slider for react native.

GIF

Installation

npm install react-native-image-slider --save

or

yarn add react-native-image-slider

Usage

import ImageSlider from 'react-native-image-slider';

// ...

render() {
  return (<ImageSlider images={[
    'http://placeimg.com/640/480/any',
    'http://placeimg.com/640/480/any',
    'http://placeimg.com/640/480/any'
  ]}/>)
}

Autoplay / Custom buttons / Custom slide / Loop

class Example extends Component<{}> {
  render() {
    const images = [
      'https://placeimg.com/640/640/nature',
      'https://placeimg.com/640/640/people',
      'https://placeimg.com/640/640/animals',
      'https://placeimg.com/640/640/beer',
    ];

    return (
      <SafeAreaView style={styles.container}>
        <View style={styles.content1}>
          <Text style={styles.contentText}>Content 1</Text>
        </View>
        <ImageSlider
          loopBothSides
          autoPlayWithInterval={3000}
          images={images}
          customSlide={({ index, item, style, width }) => (
            // It's important to put style here because it's got offset inside
            <View key={index} style={[style, styles.customSlide]}>
              <Image source={{ uri: item }} style={styles.customImage} />
            </View>
          )}
          customButtons={(position, move) => (
            <View style={styles.buttons}>
              {images.map((image, index) => {
                return (
                  <TouchableHighlight
                    key={index}
                    underlayColor="#ccc"
                    onPress={() => move(index)}
                    style={styles.button}
                  >
                    <Text style={position === index && styles.buttonSelected}>
                      {index + 1}
                    </Text>
                  </TouchableHighlight>
                );
              })}
            </View>
          )}
        />
        <View style={styles.content2}>
          <Text style={styles.contentText}>Content 2</Text>
        </View>
      </SafeAreaView>
    );
  }
}

Props

images

rendered images

customButtons

function returns custom pagination buttons component, it's got position index and move to position function as arguments

customSlide

function returns Node with arguments index - images list index, item - anything you pass inside images prop, style - for top component of your custom slide, width - calculated slide width

autoPlayWithInterval

activates autoplay when passed (it uses milliseconds)

loop

[BUGGY ON ANDROID] loops scroll of images, but in one direction only

loopBothSides

[IOS ONLY] same as loop, but does it in any direction

onPositionChanged

called when the current position is changed

position

used for controlled components

onPress

returns an object with image url and index of image pressed

style

styles ScrollView inside ImageSlider, you may pass height here (100% by default)

License

MIT

More Repositories

1

HashMap.js

< 500 byte library for HashMaps in JavaScript
HTML
93
star
2

PixelFont

A Pixel Font, written in JavaScript for the HTML5 Canvas element.
JavaScript
80
star
3

requireAsync

Require any module or file async in NodeJS.
TypeScript
21
star
4

Stream.js

500 byte library for Streams in JavaScript
JavaScript
21
star
5

HTML5WYSIWYG

A WYSIWYG editor that doesn't suck
JavaScript
15
star
6

node-brain

node-brain is a useless library for creating stupid chat bots
JavaScript
5
star
7

PaloozaAPI

Palooza's backend API service http://dev.minigamepalooza.com/api
CSS
4
star
8

Strapalooza

Custom theme based off of the Bootswatch Paper theme
CSS
3
star
9

dynamiceventlistener

Add event listeners to dynamic elements
JavaScript
3
star
10

ci-host

Easily host artifacts from your Gitlab CI server.
JavaScript
3
star
11

dom

< 1KB library for DOM selections in JavaScript
JavaScript
3
star
12

LinuxAreaSelector

C++
3
star
13

WebSocketTester

Easily test your WebSockets from the command line!
JavaScript
2
star
14

Jafig

Easily use multiple types of storage for your data
Java
2
star
15

node_nif

C++
1
star
16

NodeIRC

A modern IRC client built with the power of Node.
JavaScript
1
star
17

SkyrimTexOptimizer

Fastest Texture Optimizer for SkyrimSE
C++
1
star
18

redis-sessions-anywhere

A module for using session outside of connect/express
TypeScript
1
star
19

node_dds_opt

C++
1
star
20

ci-deploy

Easily deploy packages to another server
JavaScript
1
star
21

Test

1
star
22

ScrollbarPong

JavaScript
1
star
23

PerformanceTracker

Java
1
star
24

ServerTourPlugin

1
star
25

svelte-better-ssr

JavaScript
1
star
26

ProxyTester

A simple Java program to test http proxies!
Java
1
star
27

gtk-ffi-issue

JavaScript
1
star
28

PebblePages

Create configuration pages for your next Pebble project.
JavaScript
1
star
29

Blocks

The new Blocks format. Supports faster and more scalable Minecraft Block files.
Java
1
star
30

MiniMiniGames

This was my first minigame engine. Please do not use it, it's only here for laughs. It was created in 2013.
Java
1
star