Coder Social home page Coder Social logo

jquery-hover-delay's Introduction

jQuery Hover Delay

About

This plugin "extends" the jQuery .hover method in a simple yet powerful way. Normally the .hover method takes two arguments, handlerIn and handlerOut, which are executed when the user mouses in and out of an element respectively (for a more detailed explaination of jQuery .hover visit the jQuery docs). This plugin enables the use of a third argument, delay, to be passed to the native jQuery method. If the delay argument (which should be an integer representing milliseconds) is detected, the hover in and out handlers will wait for that amount of time before they are triggered. This produces a more natural feel in certain situations and avoids triggering hovers accidentally during unrelated mouse movements that happen to pass over a hover-enabled element. Basically the mouse must be over the element for X milliseconds before handlerIn is called, and outside of the element for X milliseconds before handlerOut is called.

There is a similar and longstanding plugin that also solves this problem called hoverIntent. Not only does it have delay, but also some more advanced options. This plugin, however, aims to be smaller, lighter, faster, and easier to work with, since it does not introduce a new method to jQuery and does not have a lot of options to configure. This plugin is also compatble with jQuery 1.9.x and will not raise errors if one forgets to include it.

Usage

$.hover(handlerIn, handlerOut); // normal .hover
$.hover(handlerInOut); // normal .hover with same handler for in/out

$.hover(handlerIn, handlerOut, delay); // enhanced .hover with delay
$.hover(handlerInOut, delay); // enhanced .hover with delay and same handler for in/out

Resources

jquery-hover-delay's People

Contributors

john-terenzio avatar

Watchers

James Cloos 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.