# react-hover-mixin

> A react mixin that will update the components state on mouse hover. Designed for tooltips, popovers, and dropdowns.

Latest version **1.1.1** (published 2015-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-hover-mixin
pnpm add react-hover-mixin
yarn add react-hover-mixin
bun add react-hover-mixin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2015-11-16 |
| First published | 2015-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | espeakers |
| Maintainers | espeakers |
| Keywords | react, mixin, hover |

## Links

- npm: https://www.npmjs.com/package/react-hover-mixin
- Repository: https://github.com/espeakers/react-hover-mixin
- Homepage: https://github.com/espeakers/react-hover-mixin#readme
- Issues: https://github.com/espeakers/react-hover-mixin/issues
- npm.io page: https://npm.io/package/react-hover-mixin

## Dependencies (1)

- [is-dom](https://npm.io/package/is-dom.md) ^1.0.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2015-11-16
- 1.1.0 — 2015-09-17
- 1.0.1 — 2015-09-17
- 1.0.0 — 2015-09-16

## README

# react-hover-mixin
A react mixin that will update the components state on mouse hover. Designed for tooltips, popovers, and dropdowns.

```js
var HoverMixin = require("react-hover-mixin");
...
... React.createClass({
  mixins: [HoverMixin],
  render: function(){
    return React.createElement("div", null,

      React.createElement("b", {
          onMouseEnter: this.hoverable_onMouseEnter,
          onMouseLeave: this.hoverable_onMouseLeave,
        },
        "[hover over me]"
      ),

      this.state.hover ? "I'm being hovered over!" : null

    );
  }
});
```

## Example
```sh
$ git clone https://github.com/espeakers/react-hover-mixin.git
$ cd react-hover-mixin/
$ npm i
$ npm start
```
Then it will tell you which port it's hosted on so you can open it in your browser.

## API

### this.state.hover
`true` or `false` depending on if it's currently being hovered over.

### this.hoverable\_onMouseEnter | this.hoverable\_onMouseLeave
These are event handlers provided by the mixin. Simply attach them to the element you wish to observe the hover state of.

For example:
```js
...
React.createElement("div", {
    onMouseEnter: this.hoverable_onMouseEnter,
    onMouseLeave: this.hoverable_onMouseLeave
  },
  ...
),
...
```

### child method: hoverable\_onUserLeftHoverable()
This is called when the component is not hovered over anymore. (after a 500ms wait to ensure the user isn't going to just hover right over it again)

### ref: "hoverable"
Set the ref to "hoverable" on the element if you want to get it's top and left position.

For example:
```js
...
React.createElement("div", {
    ref: "hoverable",
    onMouseEnter: this.hoverable_onMouseEnter,
    onMouseLeave: this.hoverable_onMouseLeave
  },
  ...
),
...
```

### this.state.hoverable\_top | this.state.hoverable\_left
The top and left position of the "hoverable" element. These are handy when trying to absolute position a tooltip or dropdown.

### this.hoverable\_not\_relative\_to\_parent\_bounding\_rect
Set this to true if your hoverable is not relative to the parent node.

```js
var HoverMixin = require("react-hover-mixin");
...
... React.createClass({
  mixins: [HoverMixin],

  hoverable_not_relative_to_parent_bounding_rect: true,

  render: function(){
    ...
  }
});
```

## Installing
```sh
$ npm install --save react-hover-mixin
```

## FYI
This project follows [semantic versioning](http://semver.org/) for releases.

## License
MIT

---
_Source: https://npm.io/package/react-hover-mixin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
