-
Notifications
You must be signed in to change notification settings - Fork 2
A simple plugin for jQuery that allows for easy mouse capturing.
benanne/jquery-mouse-capture-plugin
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
jquery.mousecapture.js version 1.2 by Sander Dieleman <sanderdieleman at gmail dot com> A simple mouse capturing plugin for jQuery. LICENSE This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. USAGE $( ... ).mousecapture({ "down": function(event, sharedData) { ... }, "move": function(event, sharedData) { ... }, "up": function(event, sharedData) { ... } }); "down", "move" and "up" are the handlers for the mousedown, mousemove and mouseup events respectively. Only "down" is required. The unmodified event object is passed to the handlers (event), as well as a blank slate object (sharedData) which can be used to store data that needs to be shared between the handlers. Alternatively, shared variables can be declared before the mousecapture call. Inside the handlers, "this" refers to the target element, just like when jQuery's regular mouse events would be used. DEMO A demo is available at: http://benanne.net/misc/jquery-plugins/mousecapture/demo.html MORE INFORMATION Read http://benanne.net/code/?p=238 for more information. CHANGES v1.2 - the context in which the down and up handlers are executed should be "$this", not "target". - moved some code around to make it smaller: it doesn't matter whether the handlers are attached / unattached before or after the actual handler is executed. At least I think it doesn't. v1.1 - added "return this" to the mousecapture method, so it conforms to the jQuery plugin authoring guidelines. v1.0 - first version
About
A simple plugin for jQuery that allows for easy mouse capturing.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published