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

rn-float-box

v0.2.3

Published

Floating box component for react-native

Downloads

12

Readme

React Native FloatingBox Component

Overview

FloatingBox is a React component designed for use in React Native applications. It leverages the react-native-gesture-handler and react-native-reanimated libraries to provide an interactive box that can be scaled and moved across the screen using gestures. This component is well-suited for applications where interactive, resizable, and movable UI elements are required, such as photo editors, interactive dashboards, or custom layout editors.

Features

  • Scalable and Movable: The FloatingBox can be resized using pinch gestures and moved across the screen with pan gestures.
  • Bounds Limiting: Incorporates logic to prevent the box from scaling beyond the screen size or moving outside the visible area.
  • Customizable: Allows for custom children to be rendered inside the box and supports customizable styling.

Installation

To integrate the FloatingBox into your project, follow these steps:

  1. Ensure you have react-native-gesture-handler and react-native-reanimated installed in your project. If not, install them using npm or yarn:

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

    or

    yarn add react-native-gesture-handler react-native-reanimated
  2. Import the FloatingBox component into your project file:

    import FloatingBox from 'rn-float-box';

Usage

Here is a basic example of how to use the FloatingBox component in a React Native application:

import React from 'react';
import { View, Text } from 'react-native';
import FloatingBox from 'rn-float-box';

const App = () => {
  return (
    <View style={{ flex: 1 }}>
      <FloatingBox
        height={100}
        width={100}
        initialProps={{ visible: true, panGestureEnabled: true, pinchGestureEnabled: true }}
        containerStyle={{ backgroundColor: 'blue' }}
      >
        <Text>Content goes here</Text>
      </FloatingBox>
    </View>
  );
};

export default App;

Props

The following table lists the props available for the FloatingBox component:

| Prop | Type | Description | Default Value | | ------------------------ | ------------------ | ------------------------------------------------------ | ------------- | | height | number | The initial height of the box. | None | | width | number | The initial width of the box. | None | | initialProps | TInitialProps | Initial visibility and gesture states. | {} | | children | ReactNode | The content to be rendered inside the box. | null | | containerStyle | ViewStyle | Additional styling for the box's container. | {} | | maxScale | number | Maximum scale factor for the box. | None | | moveAnimationDuration | number | Duration of the move animation in milliseconds. | 350 | | scaleAnimationDuration | number | Duration of the scale animation in milliseconds. | 500 | | boxProps | TBoxProps | Constraints for box resizing. | {} | | scaleProps | TScaleProps | Constraints for box scaling. | {} |

Initial Props

The initialProps prop accepts an object of type TInitialProps, which can contain the following properties:

| Property | Type | Description | Default Value | | ---------------------- | --------- | ------------------------------------------------ | ------------- | | visible | boolean | Initial visibility of the box. | true | | panGestureEnabled | boolean | Initial state of the pan gesture. | true | | pinchGestureEnabled | boolean | Initial state of the pinch gesture. | true |

Box Props

The boxProps prop accepts an object of type TBoxProps, which can contain the following properties:

| Property | Type | Description | Default Value | | ---------------------- | --------- | ------------------------------------------------ | ------------- | | minHeightClamp | number | Minimum height for the box. | height / 2 | | minWidthClamp | number | Minimum width for the box. | width / 2 | | maxHeightClamp | number | Maximum height for the box. | Screen Height | | maxWidthClamp | number | Maximum width for the box. | Screen Width |

Scale Props

The scaleProps prop accepts an object of type TScaleProps, which can contain the following properties:

| Property | Type | Description | Default Value | | ---------------------- | --------- | ------------------------------------------------ | ------------- | | minScaleClamp | number | Minimum scale factor for the box. | 0.5 | | maxScaleClamp | number | Maximum scale factor for the box. | 2 |

API Methods

FloatingBox exposes the following methods, which can be accessed using the component's ref:

| Method | Parameters | Description | | --------------------- | --------------------------- | ------------------------------------------------------------------------- | | move | position: TFloatingBoxOffset | Move the box to a new position. | | setVisible | visibility: boolean | Set the visibility of the box. | | getVisible | None | Get the current visibility of the box. | | setSizes | height: number, width: number | Set the dimensions of the box. | | getSize | None | Get the current dimensions of the box. | | setPanGestureState | enabled: boolean | Enable or disable the pan gesture. | | getPanGestureState | None | Get the current state of the pan gesture. | | setPinchGestureState| enabled: boolean | Enable or disable the pinch gesture. | | getPinchGestureState| None | Get the current state of the pinch gesture. |

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request if you find a bug or have a feature request. See the contributing guide to learn how to contribute to the repository and the development workflow.

License

This project is licensed under the MIT License.