Coder Social home page Coder Social logo

marianmoskal / magnetic-hover Goto Github PK

View Code? Open in Web Editor NEW

This project forked from halo-lab/magnetic-hover

0.0 0.0 0.0 955 KB

magneticHover lets you trigger the hover effect on the element when the cursor is near it, but not over it yet

JavaScript 93.35% HTML 6.65%

magnetic-hover's Introduction

magneticHover

magneticHover lets you trigger hover effect on the element when the cursor is near it, but not over it yet.

Magnetic hover - rotation

Examples

https://codesandbox.io/s/elegant-bogdan-eupvp?file=/src/index.js
https://codesandbox.io/s/competent-kare-tnx6t?file=/src/index.js
https://codesandbox.io/s/friendly-tdd-pdyw3?file=/src/index.js

Installation

npm install --save magnetic-hover

Usage

import MagneticHover from "../js/magneticHover";

// find target element
const elem = document.getElementById("box");

new MagneticHover({
  element: elem,
  radius: 122,
  callback: (distance) => {
    // get the distance from the cursor to the target element
    console.log(distance);
  },
});

Settings

  • element - DOM element
  • radius - how far from the target element callback should be triggered
  • callback - function that's gonna be triggered once cursor is over the range between radius and target element

Status and contribution

The project is supported by Halo lab development team, we're not working on it regularly, but trying to invest in it when we have time between clients' project.
Though, feel free to open issues and you're very welcome to contribute.

Developed in Halo lab

magnetic-hover's People

Contributors

lazio avatar dependabot[bot] avatar stoyanovk avatar aleksandr-tyagun avatar bakryu avatar mityadementiy avatar tvorohov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.