• Stars
    star
    331
  • Rank 127,323 (Top 3 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐭 Fire mouse events when a user intends it

hoverintent

hoverintent is a reworking of Brian Cherne's jQuery plugin in plain javascript. It has no dependencies.

It's goal is to determine a user's intention when hovering over an element by triggering a mouseover event when the cursor position has slowed down enough.

Check out the demo to see how it works in action.

Browser Support

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
All ✔ All ✔ 9+ ✔ 7+ ✔ All ✔

Basic usage

Adding hoverintent to an element

<script src='hoverintent.min.js'></script>
<script>
  var el = document.getElementById('element-id');
  hoverintent(el,
  function() {
    // Handler in
  }, function() {
    // Handler out
  });
</script>

Removing hoverintent from an element

<script src='hoverintent.min.js'></script>
<script>
  var el = document.getElementById('element-id');

  // Save a reference to the method
  var hoverListener = hoverintent(el,
  function() {
    // Handler in
  }, function() {
    // Handler out
  });

  // Remove hoverintent listeners
  hoverListener.remove();
</script>

Custom options

You can adjust mouse sensitivity or the length of time a mouse over/out event is fired:

<script src='hoverintent.min.js'></script>
<script>
  var opts = {
    timeout: 500,
    interval: 50
  };

  var el = document.getElementById('element-id');
  hoverintent(el,
  function() {
    // Handler in
  }, function() {
    // Handler out
  }).options(opts);
</script>
Setting Default Value Description
sensitivity
sensitivity: 7
The value (in pixels) the mouse cursor should not travel beyond while hoverintent waits to trigger the mouseover event.
interval
interval: 100
The length of time (in milliseconds) hoverintent waits to re-read mouse coordinates.
timeout
timeout: 0
The length of time (in milliseconds) before the mouseout event is fired.
handleFocus
handleFocus: false
Adds onOver/onOut callbacks to keyboard navigation during blur and focus events

Ender support

Add hoverintent as an internal chain method to your Ender compilation.

// ender add hoverintent

$('.element').hoverintent(function() {
    // Handler in
}, function() {
    // Handler out
});

Building

to manage dependencies and build. Development requires you have node.js installed.

  1. Install node.js. 'Install' will download a package for your OS.
  2. Run npm install
  3. Run npm run build

Licence

 _____
< MIT >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Bugs?

Create an issue

More Repositories

1

tablesort

↕️ A small tablesorter in plain JavaScript
JavaScript
1,095
star
2

hcl-picker

🎨 Colorpicker for data
JavaScript
207
star
3

suggestions

A typeahead component for inputs
JavaScript
45
star
4

vim-sparkup

[Depreciated] Sparkup for Vim
Python
43
star
5

superman

🎨 A dark theme for Vim
Vim Script
20
star
6

deep-linking

⚓ A deep linking and highlighting UI
JavaScript
18
star
7

forrest

💼 Geocode data with ease
JavaScript
16
star
8

dotfiles

My config
Shell
11
star
9

forsythe

A tall sans font in normal & bold
Shell
11
star
10

inverted-polygons

A friendly app for inverting polygons
JavaScript
9
star
11

datepickr

The do it yourself date picker
JavaScript
9
star
12

leaflet-interact-intent

Interact with a map when a user intends it.
JavaScript
8
star
13

ender-dragdealer

Ender integration for Ovidiu Chereches excellent drag based javascript component.
JavaScript
5
star
14

map-palette

Drag and drop or choose a palette to style a map
CSS
5
star
15

geojson-to-image

Pass GeoJSON and get an image in return from Mapbox Static API
JavaScript
4
star
16

tristen.github.com

HTML
4
star
17

toronto-map

A TileMill map of Toronto.
4
star
18

maplist

Create a list of things on a map!
JavaScript
3
star
19

picture-map

WIP
JavaScript
3
star
20

vintages

Search LCBO's catalogue of vintages fast.
JavaScript
3
star
21

sotmus2015

CSS
2
star
22

map-controls

JavaScript
2
star
23

mm-examples

A prototype code examples site using Jekyll with gists and bl.ocks
JavaScript
2
star
24

wookie

Basic HTTP cookie handling.
JavaScript
2
star
25

scholar

Scholar is a Drupal starter theme for the University of Toronto
PHP
1
star
26

stream-o-tweet

Streams a tweet using socket.io and node-twitter.
JavaScript
1
star
27

radioplay

A one page interactive that demonstrates wax and layer switching
JavaScript
1
star
28

toronto-open-data

toronto.ca/open data converted into readable formats for GitHub
1
star
29

regex-js

An expression editor/visualizer
JavaScript
1
star
30

tilemill-tablesort

A plugin that adds sorting to the data features table
JavaScript
1
star
31

beamapper

web site to recruit mappers to OpenStreetMap.org
1
star
32

presentations

HTML
1
star
33

demos

JavaScript
1
star
34

chart-to-map

Experimental utility for matching SVG elements to Mapbox GL style templates.
JavaScript
1
star