npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery-fixclick

v1.0.0

Published

With this plugin you can safely bind to both click and double click (dblclick) events and only have the appropriate one execute when the user clicks/double-clicks.

Downloads

36

Readme

jquery-fixclick

augmented clone/fork of AlloVince's fixclick plugin - his site is down so this is based on the v1.0 floating around...

Original / references to the original

  • http://allo.ave7.net/
  • http://www.jquery-plugins.info/fixclick-00012763.htm

References discussing the problem (mixing .click() and .dblclick())

  • http://api.jquery.com/dblclick/

    Also pay attention to the note near the end where it says:

    It is inadvisable to bind handlers to both the click and dblclick events for the same element. [...]

  • http://stackoverflow.com/questions/6330431/jquery-bind-double-click-and-single-click-separately

  • https://gist.github.com/ncr/399624

  • http://stackoverflow.com/questions/1067464/need-to-cancel-click-mouseup-events-when-double-click-event-detected/1067484#1067484

  • http://stackoverflow.com/questions/5471291/javascript-with-jquery-click-and-double-click-on-same-element-different-effect

Problem

When you bind both the single click and double click (dblclick) event on a DOM element, the click handler will fire once (or twice) before the dblclick handler is invoked.

Solution

With this plugin you can safely bind to both click and double click (dblclick) events and only have the appropriate one execute when the user clicks/double-clicks.

Note that the single-click event will be delayed by about 300 ms. This is unfortunately necessary to discern between both events.

Usage

Example usage:

$("#test").fixClick(function (e) {
  // do something here when click
  //
  // Note: this handler will be delayed! 
  // ($.fn.fixClick.clickDelay = 300 milliseconds by default)
  //
  // `e` event object is a clone of the original event and has
  // its `.simulated` field set to boolean `true`.
  ...
}, function (e) {
  // do something here when dblclick
  //
  // `e` is the usual event object you'ld expect for any jQuery
  // dblclick action. 
  ...
});

Enhanced example usage:

$("#test").fixClick(function (e) {
  // do something here when click
  //
  // Note: this handler will be delayed! 
  // ($.fn.fixClick.clickDelay = 300 milliseconds by default)
  //
  // `e` event object is a clone of the original event and has
  // its `.simulated` field set to boolean `true`.
  ...
}, function (e) {
  // do something here when dblclick
  //
  // `e` is the usual event object you'ld expect for any jQuery
  // dblclick action. 
  ...
}, function (e) {
  // this optional handler gets invoked *immediately* when
  // a click event arrives. Here you may perform some app-specific
  // setup/signaling.
  //
  // Warning/Note: this handler is, of course, invoked for each
  // click event, hence it will also be invoked for a dblclick.
  // When you wish jQuery-FixClick to *not* set up and fire a
  // delayed click handler (the first argument of this fixClick()
  // call), you can accomplish this by invoking
  // `e.stopImmediatePropagation()`.
  ...
  if (some_condition_where_you_dont_want_the_delayed_click_called) {
    e.stopImmediatePropagation();
  }
});