React Native Animated Pagination Dot

0.4.0 · maintenance · verified Tue Apr 21

This package provides an animated pagination dot component for React Native applications, designed to visually indicate the current page in a scrollable view or carousel with a distinct moving animation. It primarily offers a simple, customizable solution for pagination with smooth transitions between active dots. The current stable version is 0.4.0, last updated in September 2022. While development activity has been infrequent since its last major update, the library is stable and functional for its intended purpose. It differentiates itself from static pagination components through its built-in dot animation logic.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a basic implementation of `PaginationDot` in a React Native component. It shows how to import the component, set required props like `curPage` and `maxPage`, and customize colors. A `useState` hook manages the current page index, which automatically cycles for illustrative purposes.

import React, { useState } from 'react';
import { View, StyleSheet } from 'react-native';
import PaginationDot from 'react-native-animated-pagination-dot';

const ExampleDotPaginate: React.FC = () => {
    const [curPage, setCurPage] = useState(0);
    const maxPages = 5; // Simulate 5 pages

    // In a real application, curPage would likely be tied to a FlatList's onScroll event
    // or a carousel's active index.
    // For demonstration, we'll increment it on a timer or a button press.

    React.useEffect(() => {
        const interval = setInterval(() => {
            setCurPage(prevPage => (prevPage + 1) % maxPages);
        }, 2000); // Change page every 2 seconds
        return () => clearInterval(interval);
    }, [maxPages]);

    return (
        <View style={styles.container}>
            <PaginationDot
                activeDotColor={'#1da1f2'} // Twitter blue
                inactiveDotColor={'#cccccc'}
                curPage={curPage}
                maxPage={maxPages}
                sizeRatio={1.2}
                vertical={false} // Default, explicitly set for clarity
            />
        </View>
    );
};

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#f0f0f0',
    },
});

export default ExampleDotPaginate;

view raw JSON →