Socket
Book a DemoInstallSign in
Socket

@olc-digital/react-parallax-hook

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@olc-digital/react-parallax-hook

An easy to use and customisable parallax implementation

0.0.9
latest
Source
npmnpm
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

react

FAQs

Package last updated on 28 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.