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

react-drifting-component

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-drifting-component

Drifting react component

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

react-drifting-component

The drifting component which allows you to drift on the screen :) The component uses mousemove event for desktops and deviceorientation for mobile devices.

Installation

$ npm install react-drifting-component

Demo

Try it out

Basic Usage

import { Drifting } from 'react-drifting-component';

// Inside of a component's render() method:
render() {
  return (
    <Wrapper>
      <Drifting maxMouseRange={15} maxOrientationRange={15}>
        {({ ref }) => <Background ref={ref} />}
      </Drifting>

      <Drifting maxMouseRange={50} maxOrientationRange={20} reverse>
        {
          ({ pos, onRef }) =>
            <Text ref={ref} text="Drifting component" className="title" />
        }
      </Drifting>
    </Wrapper>
  );
}

Examples

Please clone the repo and run npm run storybook or yarn storybook to show examples of usages.

Usage (API)

The Drifting component has a few properties, as described below.

NOTE: this component uses rAF(requestAnimationFrame) if you need to support old browsers ensure that you are using polyfill for rAF!

PropertyTypeDefautDescription
reversebooleanfalseReverse drifting
childrenfunction({ pos: { x, y } }, onRef: () => ref)A function that gets an object with pos and onRef keys as an argument. Pos contains x: number and y: number, this numbers should pass to your component style to allow drift. onRef it is function which should be passed to ref of your component
maxMouseRangenumbernullMax mouse drift range.
maxOrientationRangenumbermaxMouseRangeMax orientation drift range. devices.

Contributing

I welcome contributions! Please open an issue if you have any feature ideas or find any bugs. I also accept pull requests with open arms. I will go over the issues when I have time. :)

Keywords

FAQs

Package last updated on 20 Feb 2024

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