Code Monkey home page Code Monkey logo

longclick's Introduction

jQuery Long Click Event

Press & hold mouse/touch "long click" special event for jQuery 1.4.x. Inspired by similar events on touch-sensitive devices.

Using Long Click:

.click( duration, handler )

  • Simply supply duration to the well-known .click method and you have a long click.
  • This method is a shortcut for .bind("longclick", handler).
  • Returns jQuery.

or .longclick( [ duration ], [ handler ] )

  • If supplied, optional custom duration is used for target element(s).
  • This method is a shortcut for .click(duration, handler) when at least handler is supplied and for .trigger("longclick") if called without arguments.
  • Returns jQuery.

Parameter duration:

  • For how long (in milliseconds) mouse button must be pressed down (or touched) stationery to qualify as a long click.
  • False value results in using the configured default.
  • Default duration is 500 and is stored in jQuery.longclick.duration variable.

Event "longclick":

Requirements:

  1. Mighty jQuery 1.4.x:

    <script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>

  2. and jquery.longclick-min.js (~1 kB):

    <script src='jquery.longclick-min.js' type='text/javascript'></script>

License:

Free for use in all personal or commercial projects under both MIT and GPL licenses.

Fair Warning:

Under intensive loving development. v0.x works just fine, but is very "fluid" API-wise. Till v1.0.


Copyright (c) 2010 Petr Vostřel » Check out my other jQuery plugin Reel for 360° image projection

longclick's People

Contributors

pisi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

longclick's Issues

Android Compatibility?

Hello, first off, great plugin!

I was viewing your example.html on my Android device, and noticed it wasn't triggering the long press, any ideas?

Thanks!

Is there a way to detect when the longclick has ended?

I'm adding a style after the longclick and would like to remove it when the longclick is over (either the user end the click or start moving the mouse/finger). My code looks like this right now:

$('.draggable').click(500, function() {
  $(this)
    .addClass("ui-draggable-hover");
});

Thanks in advance!

longclick still triggering normal click

Hi,

Thanks for this plugin, its just what I am looking for but I noticed that when I run the example.html you've provided I still get the normal click event triggering after the long click. I'm trying on windows vista in firefox and chrome.

Thanks

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.