All Projects → mkosir → React Hook Mighty Mouse

mkosir / React Hook Mighty Mouse

Licence: mit
🐭 React hook that tracks mouse events on selected element - zero dependencies

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Hook Mighty Mouse

LowLevelInput.Net
A thread safe and event driven LowLevelMouse and LowLevelKeyboard Hook
Stars: ✭ 32 (-57.33%)
Mutual labels:  hook, mouse
Neatinput
A .NET standard project which aims to make keyboard and mouse input monitoring easy on Windows and eventually Linux.
Stars: ✭ 89 (+18.67%)
Mutual labels:  hook, mouse
Robotgo
RobotGo, Go Native cross-platform GUI automation @vcaesar
Stars: ✭ 7,095 (+9360%)
Mutual labels:  hook, mouse
creviceapp
Multi purpose utility which supports gestures with mouse and keyboard.
Stars: ✭ 22 (-70.67%)
Mutual labels:  hook, mouse
MouseInjectDetection
Simple method of checking whether or not mouse movement or buttons (<windows 10) are injected
Stars: ✭ 29 (-61.33%)
Mutual labels:  hook, mouse
Rbtray
A fork of RBTray from http://sourceforge.net/p/rbtray/code/.
Stars: ✭ 365 (+386.67%)
Mutual labels:  hook, mouse
Silence
A simple, clean macro recorder written in C#. Windows 10 compatible.
Stars: ✭ 29 (-61.33%)
Mutual labels:  hook, mouse
Fontmod
Simple hook tool to change Win32 program font.
Stars: ✭ 1,064 (+1318.67%)
Mutual labels:  hook
Use Delayed Render
react hook for delaying the render and unmount of a component
Stars: ✭ 62 (-17.33%)
Mutual labels:  hook
Xpatch
免Root实现app加载Xposed插件工具。This is a tool to repackage apk file, then the apk can load any xposed modules installed in the device. It is another way to hook an app without root device.
Stars: ✭ 1,054 (+1305.33%)
Mutual labels:  hook
React Intersection Visible Hook
React Hook to track the visibility of a functional component
Stars: ✭ 46 (-38.67%)
Mutual labels:  hook
Hrcarmarkeranimation
This android library is helpful for google map marker animation with Smooth turn and movement.
Stars: ✭ 52 (-30.67%)
Mutual labels:  location
React Hook Tutorial
React Hook 系列教程,学习和探索Hooks世界。
Stars: ✭ 65 (-13.33%)
Mutual labels:  hook
Lenz
Console based MAP 🗺 : with lots of features 🤩
Stars: ✭ 51 (-32%)
Mutual labels:  location
Sandhook
Android ART Hook/Native Inline Hook/Single Instruction Hook - support 4.4 - 11.0 32/64 bit - Xposed API Compat
Stars: ✭ 1,172 (+1462.67%)
Mutual labels:  hook
Teliver Android
Realtime Live Tracking of Location made Easy.
Stars: ✭ 49 (-34.67%)
Mutual labels:  location
Wechat Pc Hook Ws
微信PcHooker websocket api
Stars: ✭ 74 (-1.33%)
Mutual labels:  hook
Ktmm
Keep That Mouse Moving!
Stars: ✭ 70 (-6.67%)
Mutual labels:  mouse
Indoorgps
Position Calculating with Trilateration via Bluetooth Beacons(Estimote)
Stars: ✭ 59 (-21.33%)
Mutual labels:  location
S Mvp
🔥🔥优化版MVP,使用注解泛型简化代码编写,使用模块化协议方便维护,APT过程使用注解解析器利用JavaPoet🌝完成重复模块的编写,利用ASpect+GradlePlugin 完成横向AOP编程+Javassist动态字节码注入+Tinker实现热修复+Retrofit实现优雅网络操作+RxJava轻松玩转数据处理
Stars: ✭ 1,095 (+1360%)
Mutual labels:  hook

React Mighty Mouse Mighty Mouse

npm version npm bundle size Build Status

React hook that tracks mouse events on selected element.

Demo

Demos created with React DemoTab 📑

Install

npm install react-hook-mighty-mouse

Features

  • Lightweight, zero dependencies 📦
  • Supports mouse and touch events
  • Mouse positions 🖱️ - client/page/screen 🔗demo
  • Mouse relative position to selected element 🔗demo
  • Mouse angle 0-360° 📐 relative to selected element 🔗demo - Eyes Follow 👀 🔗demo
  • Track mouse button events 🔗demo
  • Detect when mouse is hovering over selected element 🔗demo
  • Detect keys pressed on the keyboard ⌨️ 🔗demo

Example

import React from 'react';
import useMightyMouse from 'react-hook-mighty-mouse';

const App = () => {
  const { position } = useMightyMouse();
  return (
    <div>
      Mouse position x:{position.client.x} y:{position.client.y}
    </div>
  );
};

ReactDOM.render(<App />, document.getElementById('root'));

Hook

useMightyMouse(
  touchEnabled: boolean = true,
  selectedElementId: string | null = null,
  selectedElementOffset: { x: number; y: number } = { x: 0, y: 0 }
  ): Mouse

▶︎ indicates the default value if there's one

Input Params

touchEnabled: boolean ▶︎ true
Boolean to enable/disable touch.

selectedElementId: string | null ▶︎ null
Selected element id.

selectedElementOffset: { x: number; y: number } ▶︎ { x: 0, y: 0 }
Selected element offset object.

Return values

Mouse = {
  position : {
    client : { x : number | null, y : number | null },
    screen : { x : number | null; y : number | null },
    page : { x : number | null; y : number | null },
  },
  buttons : {
    left : boolean | null,
    middle : boolean | null,
    right : boolean | null,
  },
  keyboard : {
    ctrl : boolean | null,
    shift : boolean | null,
    alt : boolean | null,
  },
  eventType : string | null,
  selectedElement : {
    position : { x : number | null; y : number | null, angle : number | null },
    boundingRect : { left : number | null; top : number | null, width : number | null, height : number | null },
    isHover : boolean
  },
}

Development

Easily set up a local development environment!

Build all the examples and starts storybook server on localhost:9009:

  • clone
  • npm install
  • npm start

OR

Clone this repo on your machine, navigate to its location in the terminal and run:

npm install
npm link # link your local repo to your global packages
npm run build:watch # build the files and watch for changes

Clone project repo that you wish to test with react-hook-mighty-mouse library and run:

npm install
npm link react-hook-mighty-mouse # link your local copy into this project's node_modules
npm start

Start coding! 🎉

Contributing

All contributions are welcome!

Roadmap

  • Add throttle parameter (hook "updating")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].