Socket
Socket
Sign inDemoInstall

@react-spring/shared

Package Overview
Dependencies
3
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-spring/shared


Version published
Weekly downloads
1.4M
decreased by-17.82%
Maintainers
1
Install size
112 kB
Created
Weekly downloads
 

Package description

What is @react-spring/shared?

@react-spring/shared is a utility package that provides shared functionalities for the react-spring animation library. It includes various utilities and helpers that are used internally by react-spring to manage animations, handle interpolation, and manage state.

What are @react-spring/shared's main functionalities?

Interpolation

The interpolate function allows you to map input ranges to output ranges. In this example, the input range [0, 1] is mapped to the output range [10, 20], and the value 0.5 is interpolated to 15.

const { interpolate } = require('@react-spring/shared');

const interpolatedValue = interpolate([0, 1], [10, 20]);
console.log(interpolatedValue(0.5)); // Outputs: 15

Animation Management

The createInterpolator function is used to create custom interpolators for animations. This example demonstrates creating an interpolator that maps the range [0, 1] to [0, 100], and interpolates the value 0.5 to 50.

const { createInterpolator } = require('@react-spring/shared');

const interpolator = createInterpolator({ range: [0, 1], output: [0, 100] });
console.log(interpolator(0.5)); // Outputs: 50

State Management

The useSpring hook is used to manage the state of animations. This example shows how to initialize an animation state with an opacity of 1 and then update it to 0.

const { useSpring } = require('@react-spring/shared');

const [props, set] = useSpring(() => ({ opacity: 1 }));
set({ opacity: 0 });
console.log(props.opacity); // Outputs: 0

Other packages similar to @react-spring/shared

Readme

Source

@react-spring/shared

Various helpers used by @react-spring/core and/or the platform targets (eg: @react-spring/web).

Notable exports:

  • The Globals object (updated with its assign method)
  • The createStringInterpolator function
  • The createInterpolator function
  • The normalizeColor function
  • The FrameLoop class
  • The colors object
  • The colorToRgba function
  • The FluidValue class and related functions

Keywords

FAQs

Last updated on 04 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc