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

next-locomotive-scroll

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-locomotive-scroll

Locomotive scroll wrapper for NEXT.JS

  • 2.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-90%
Maintainers
1
Weekly downloads
 
Created
Source

Next Locomotive Scroll

An implementation / wrapper of locomotive-scroll for Next.JS with built in integration with GSAP

Usage

Usage is pretty straight forward:

{/* Simply add the component to the root of your page */}
<NextLocomotiveScroll
    // Configure it with any options you'd use with locomotive-scroll
    options={{
        lerp: 0.133
    }}
    // Optionally integrate it with GSAP ScrollTrigger
    gsap={true}
>
    {/* And add your page's children */}
    <div>Lorem ipsum dolor sit, amet consectetur adipisicing elit.</div>
</NextLocomotiveScroll>

To use GSAP tweens with ScrollTrigger a little extra code is needed:

{/* Add these two lines to track page loaded state */}
const [loaded, __setLoaded] = useState(false);
useEffect(() => document.readyState === "complete" ? __setLoaded(true) : window.addEventListener("load", () => __setLoaded(true)), []);
useEffect(() => {
    {/* Place all gsap-related content in a gsap context like normal */}
    const ctx = gsap.context(() => {
        {/* Everything else is normal */}
        gsap.to(polaroidsRef.current, {
            x: `-${100 * polaroidsScale}%`,
            scale: polaroidsScale,
            scrollTrigger: {
                scrub: true,
                trigger: polaroidsRef.current,
                end: "bottom"
            }
        });
    });

    return () => ctx.revert();
}, [
    {/* Except down here... Make sure to add the loaded state to the dependency array */}
    loaded
]);

Keywords

FAQs

Package last updated on 03 Sep 2023

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