Socket
Book a DemoInstallSign in
Socket

click-opacity

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
Package was removed
Sorry, it seems this package was removed from the registry

click-opacity

opacity on click

1.0.0
unpublished
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Description

click-opacity is a react hook that adds opacity to button on mouse down and removed when the mouse is up or leaves, it returns two functions;

  • add(el);
  • remove(el);

Where el is the button/element to which click opacity will be added. add(el) is called by mousedown event handler while remove(el) is called by both mouseup and mouseleave event handlers

The click-opacity receives an optional argument to set the opacity value

Installation

    npm i @mozeyinedu/click-opacity

How to use click-opacity

    import {useRef} from 'react';
    import clickOpacity from 'click-opacity';

    export function Button(){

        const btnRef = useRef();
        const { add, remove } = clickOpacity(0.5);

        return (
            <button
                ref={btnRef}
                onMouseDown={()=>add(btnRef.current)}
                onMouseUp={()=>remove(btnRef.current)}
                onMouseLeave={()=>remove(btnRef.current)}
            >Click Me</button>
        )
    }

Keywords

opacity

FAQs

Package last updated on 03 May 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.