npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-before-after-slider

v1.1.1

Published

A React Native component for creating before and after image sliders.

Downloads

12

Readme

react-native-before-after-slider

A lightweight and customizable React Native component for creating before and after image sliders using react-native-reanimated and react-native-gesture-handler.

Features

  • Smooth and performant animations using Reanimated 2
  • Highly customizable with styled-components
  • Easy to integrate into any React Native project

Installation

Using npm

First, install the necessary dependencies:

npm install react-native-reanimated react-native-gesture-handler styled-components

Then, install the react-native-before-after-slider package:

npm install react-native-before-after-slider

Using yarn

yarn add react-native-reanimated react-native-gesture-handler styled-components

Then, install the react-native-before-after-slider package:

yarn add react-native-before-after-slider

Make sure to follow the setup instructions for react-native-reanimated and react-native-gesture-handler if you haven't already.

Reanimated Setup

  1. Add Reanimated's Babel plugin to your babel.config.js:
module.exports = {
  presets: ["module:metro-react-native-babel-preset"],
  plugins: ["react-native-reanimated/plugin"],
};
  1. Wrap your app with Reanimated's GestureHandlerRootView:
import "react-native-gesture-handler";
import React from "react";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { enableScreens } from "react-native-screens";
import MainScreen from "./screens/MainScreen";

enableScreens();

const Stack = createStackNavigator();

export default function App() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <NavigationContainer>
        <Stack.Navigator>
          <Stack.Screen name="Main" component={MainScreen} />
        </Stack.Navigator>
      </NavigationContainer>
    </GestureHandlerRootView>
  );
}

Usage

Here is a basic example of how to use the BeforeAfterSlider component:

import React from "react";
import { View } from "react-native";
import { BeforeAfterSlider } from "react-native-before-after-slider";

const beforeImage = require("./path-to-before-image.jpg");
const afterImage = require("./path-to-after-image.jpg");
const delimiterIcon = require("./path-to-icon.png");

const App = () => {
  return (
    <View style={{ flex: 1 }}>
      <BeforeAfterSlider
        beforeImage={beforeImage}
        afterImage={afterImage}
        handleWidth={30}
        handleColor="blue"
        delimiterIcon={delimiterIcon}
        delimiterIconStyles={{ width: 30, height: 30, tintColor: "red" }} // Customize the styles here
      />
    </View>
  );
};

export default App;

Props

BeforeAfterSlider Props

| Prop | Type | Default | Description | | --------------------- | --------------------- | -------- | ---------------------------------------------------- | | beforeImage | ImageSourcePropType | Required | The source for the before image. | | afterImage | ImageSourcePropType | Required | The source for the after image. | | handleWidth | number | 20 | The width of the slider handle. | | handleColor | string | 'white' | The color of the slider handle. | | delimiterIcon | ImageSourcePropType | Optional | The source for the delimiter icon inside the handle. | | delimiterIconStyles | object | {} | Styles for the delimiter icon. |

Contributing

Contributions are welcome! Please open an issue or submit a pull request to discuss any changes.

License

This project is licensed under the MIT License.