1.0.1 • Published 4 years ago

expo-instagram-stories v1.0.1

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

Expo Instagram Stories

A Javascript slideshow component for React-Native (Android and iOS). React-Native-Timed-Slideshow, as the name suggests, is a Slideshow component with timed animation. It uses Animated library from React-Native, with native driver (only native animations).

Original Concept

Original Concept

My Component

demo

Getting Started

Installation

npm install react-native-timed-slideshow --save

Basic Usage

import TimedSlideshow from 'react-native-timed-slideshow';
	render() {
		const items = [
			{
				uri: "http://www.lovethemountains.co.uk/wp-content/uploads/2017/05/New-Outdoor-Sports-and-Music-Festival-For-Wales-4.jpg",
				title: "Michael Malik",
				text: "Minnesota, USA",
			},
			{
				uri: "http://blog.adrenaline-hunter.com/wp-content/uploads/2018/05/bungee-jumping-barcelona-1680x980.jpg",
				title: "Victor Fallon",
				text: "Val di Sole, Italy",
				duration: 3000
			},
			{
				uri: "https://greatist.com/sites/default/files/Running_Mountain.jpg",
				title: "Mary Gomes",
				text: "Alps",
				fullWidth: true
			}
		]

		return (
			<TimedSlideshow
				items={items}
			/>
		);
	}

API

Properties

PropertyTypeDefaultDescription
itemsobject-(Required at least 2 items) Sliders items.
loopbooleantrueBoolean that is used to determine if the slideshow should be or not in loop
durationnumber5000Each slide duration on screen (in milliseconds)
indexnumber0First Slide to appear
extraSpacingnumber10% of widthExtra spacing each slide will have. This extra spacing basically represents the width that each image slides (eg. 300)
fullWidth*booleanfalseOption that makes the image show it's full width in the animation, by using the Image.getSize from React-Native (later calculated to keep the screens ratio), and if true it will override the extraSpacing if it's set
progressBarColorstringnullOption to change progress bar color
showProgressBarbooleantrueOption to show or hide progress bar
progressBarDirectionstringnullThree options (fromLeft, fromRight, middle - null)
slideDirectionstring"even"Direction of the each slide animation. Values are "even", "odd", "left", "right". Basically even means first slide goes from left-to-right, second slide goes from right-to-left and so on. Odd is opposite, left means all slides com from left-to-right and right means all slides come from right-to-left
footerStylestylenullFooter titles style
titleStylestylenullFooter titles style
textStylestylenullFooter text style
renderItemfuncnullComplete control of the rendered item, with one object param with 3 params ({ item, index, focusedIndex })
renderFooterfuncnullComplete control of the footer, with one object param with 5 params ({ item, index, focusedIndex, defaultStyle, animation }) the animation param is an object with the following { titleTranslateY, textTranslateY, opacity }
renderIconfuncnullComplete control of the icon rendered in the footer, with on param ({ snapToNext }) function to snap immediately to the next slide
renderCloseIconfuncnullComplete control of the close icon rendered in the "header", with on param ({ wrapperStyle, imageStyle, onPress }) style used in the view with icon, style for the icon, and the onPress function that is passed
onClosefuncnullFunction that is triggered when the close icon is clicked

Items Properties

PropertyTypeDescription
uristring/numberThe image url or number (if local image, the require returns a number instead)
titlestringThe slide item's title
textstringThe slide item's text or description
durationnumberThe individual slide time, this way you can customize individually how much time each slide can appear on screen
directionstringThe individual slide direction animation, Values are "even", "odd", "left", "right"
extraSpacingnumberThe individual slide extra spacing, this way you can define how much width the image can slide on screen
fullWidth*booleanThe individual slide width, if true the Image.getSize from React-Native will calculate the image's full width (later calculated to keep the screens ratio), and if true it will override the extraSpacing if it's set

*This function is explained in the React-Native docs in the Image component if you want to check-out

Image Wrapper

The Image-Wrapper is a sub-component from Timed-Slideshow, it controls each image individual animation.

Usage

import { ImageWrapper } from 'react-native-timed-slideshow';
// Basic Usage
<ImageWrapper uri='https://greatist.com/sites/default/files/Running_Mountain.jpg' />

Properties

PropertyTypeDescription
uristring/numberThe image url or number (if local image, the require returns a number instead)
indexnumberThe image's index
durationnumberDuration of the images animation
focusedIndexnumberThe focused image index
extraSpacingnumberExtra spacing of the images animation
fullWidthbooleanThe individual slide width, if true the Image.getSize from React-Native will calculate the image's full width (later calculated to keep the screens ratio), and if true it will override the extraSpacing if it's set
directionstringThe individual slide direction animation, Values are "even", "odd", "left", "right"

Acknowledgement

Eric Hoffman who designed the concept on dribble for Reform Collective and who inspired me to create the component and challenge my knowledge on React-Native and animations in the framework.

License

MIT.