Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-parallax-hook

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-parallax-hook

An easy to use and customisable parallax implementation

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React useParallax hook (Beta)

A simple hook for easily implementing Parallax.

import { useParallax } from 'react-parallax-hook';
const parallaxRef = useParallax();

return (
  <>
    <div ref={parallaxRef()} />
    <img ref={parallaxRef({ multiplier: -120, from: 'top' })}>
  </>
)

the parallaxRef method accepts these options:

{
  multiplier?: number; // default: -60
  from?: 'center' | 'top'; // default: 'center'
}

Performance

A single window.onScroll event is used per component. Parallax values are only calculated for elements that are in view (according to IntersectionObserver). Every observer is destroyed when no longer in use.

Todo

  • ✅ Use intersection observer to improve performance
  • Typescript declarations
  • Add property as an option

Keywords

FAQs

Package last updated on 25 Apr 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc