1.0.6 • Published 5 years ago

react-native-viewsfan v1.0.6

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
5 years ago

ViewsFan

This library allows to place views in a fan shape as shown below:

Examples

3 views

3 views

5 views

5 views

Setup

npm

npm install react-native-viewsfan

yarn

yarn add react-native-viewsfan --save

Integration example

import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import ViewsFan from "react-native-viewsfan"

export default class App extends Component {

    views = [];

    constructor(props) {
        super(props);
        const array = [], val = 5;

        for (let i = 0; i < val; i++)
            array.push(<View style={{borderRadius: 10, width: 70, height: 70, backgroundColor: i % 2 === 0 ? i === 0 ? "green" : "blue" : "red"}} />)
        this.views = array;
    }

    render() {
        return (
            <View style={styles.container}>
                <ViewsFan verticalOffset={20} horizontalOffset={15} maxAngle={40}  views={this.views} reverseOverlap={false}/>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
});

Props

NameDescriptionRequiredDefault Value
views: View[]Array containing your viewsyesnone
verticalOffset: numberDefines by how much each view will be under its neighbourno20
horizontalOffset: numberDefines the marginRight to apply to each viewno20
maxAngle: numberDefines the maximum angle the edge's views can haveno45 (deg)
reverseOverlap: booleanWhether or not the overlap should act as last view's zIndex > ... > first view's zIndexnofalse
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago