🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

use-lax

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-lax

React hook to use with lax.js.

latest
Source
npmnpm
Version
4.0.4
Version published
Weekly downloads
9
-73.53%
Maintainers
1
Weekly downloads
 
Created
Source

use-lax

npm All Contributors

React hook to use with lax.js.

Usage

import React from 'react';
import { useLax, useLaxElement } from 'use-lax';

function App() {
  const [showBubble, setBubble] = useState(false);
  const toggleBubble = () => setBubble(!showBubble);

  // Use once in the top level element
  // to configure drivers and initial elements
  // https://github.com/alexfoxy/lax.js#setup
  useLax({
    drivers: [
      {
        name: 'scrollY',
        getValueFn: () => window.scrollY,
      },
    ],
  });

  return (
    <div>
      <button className="toggle-bubble" onClick={toggleBubble}>
        Toggle Bubble
      </button>
      <p>{showBubble ? '...now scroll down...' : '^ press the button ^'}</p>
      {showBubble ? <Bubble /> : null}
    </div>
  );
}

function Bubble() {
  // Use it on every component added dynamically
  // and provide the animation driven from the drivers
  const ref = useLaxElement({
    animationData: {
      scrollY: {
        presets: ['fadeInOut:200:0'],
        translateX: [
          [0, 'screenHeight'],
          [0, 'screenWidth'],
        ],
      },
    },
  });

  return <div ref={ref} className="bubble" />;
}

Contributors

Thanks goes to these wonderful people (emoji key):


Arthur Denner

💻 🎨 📖 💡 🤔 🚧

Antoine Martin

đź’»

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

react

FAQs

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