jquery.event.ue
Advanced tools
Comparing version 1.2.5 to 1.3.0
@@ -111,3 +111,3 @@ /* | ||
if ( input_list.remove_val ) { | ||
console.warn( 'The array appears to already have listPlus capabilities' ); | ||
// The array appears to already have listPlus capabilities | ||
return input_list; | ||
@@ -133,2 +133,3 @@ } | ||
// Begin define special event handlers | ||
/*jslint unparam:true */ | ||
Ue = { | ||
@@ -143,5 +144,2 @@ setup : function( data, name_list, bind_fn ) { | ||
// jslint hack to allow unused arguments | ||
if ( data && bind_fn ) { console.log( 'unused arguments' ); } | ||
// if previous related event bound do not rebind, but do add to | ||
@@ -171,4 +169,4 @@ // type of event bound to this element, if not already noted | ||
$to_bind.bind( 'mousedown' + ue_namespace_code, onMouse ); | ||
$to_bind.bind( 'touchstart' + ue_namespace_code, onTouch ); | ||
$to_bind.on( 'mousedown' + ue_namespace_code, onMouse ); | ||
$to_bind.on( 'touchstart' + ue_namespace_code, onTouch ); | ||
} | ||
@@ -179,8 +177,8 @@ | ||
if ( ! isMoveBound ) { | ||
// console.log('first element bound - adding global binds'); | ||
$(document).bind( 'mousemove.__ue', onMouse ); | ||
$(document).bind( 'touchmove.__ue', onTouch ); | ||
$(document).bind( 'mouseup.__ue' , onMouse ); | ||
$(document).bind( 'touchend.__ue' , onTouch ); | ||
$(document).bind( 'touchcancel.__ue', onTouch ); | ||
// first element bound - adding global binds | ||
$(document).on( 'mousemove.__ue' , onMouse ); | ||
$(document).on( 'touchmove.__ue' , onTouch ); | ||
$(document).on( 'mouseup.__ue' , onMouse ); | ||
$(document).on( 'touchend.__ue' , onTouch ); | ||
$(document).on( 'touchcancel.__ue' , onTouch ); | ||
isMoveBound = true; | ||
@@ -289,5 +287,5 @@ } | ||
ue_namespace_code = '.__ue' + namespace_key; | ||
$bound.unbind( 'mousedown' + ue_namespace_code ); | ||
$bound.unbind( 'touchstart' + ue_namespace_code ); | ||
$bound.unbind( 'mousewheel' + ue_namespace_code ); | ||
$bound.off( 'mousedown' + ue_namespace_code ); | ||
$bound.off( 'touchstart' + ue_namespace_code ); | ||
$bound.off( 'mousewheel' + ue_namespace_code ); | ||
} | ||
@@ -300,8 +298,8 @@ | ||
if ( boundList.length === 0 ) { | ||
// console.log('last bound element removed - removing global binds'); | ||
$(document).unbind( 'mousemove.__ue'); | ||
$(document).unbind( 'touchmove.__ue'); | ||
$(document).unbind( 'mouseup.__ue'); | ||
$(document).unbind( 'touchend.__ue'); | ||
$(document).unbind( 'touchcancel.__ue'); | ||
// last bound element removed - removing global binds | ||
$(document).off( 'mousemove.__ue'); | ||
$(document).off( 'touchmove.__ue'); | ||
$(document).off( 'mouseup.__ue'); | ||
$(document).off( 'touchend.__ue'); | ||
$(document).off( 'touchcancel.__ue'); | ||
isMoveBound = false; | ||
@@ -311,2 +309,3 @@ } | ||
}; | ||
/*jslint unparam:false */ | ||
// End define special event handlers | ||
@@ -313,0 +312,0 @@ //--------------- BEGIN JQUERY SPECIAL EVENTS ---------------- |
{ "name": "jquery.event.ue", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"description": "Respond to Touch and Desktop events using the same handlers, including tap (click), long-press, drag, long-press-drag, pinch/mouse zoom. Used in commercial SPAs and featured in the best-selling book Single Page Web Applications - JavaScript end-to-end.", | ||
@@ -4,0 +4,0 @@ "keywords": [ |
# jquery.event.ue | ||
## Summary | ||
Use this **unified event** plugin to applications that easily and seamlessly support | ||
mobile (touch) **and** desktop (mouse) environments. | ||
Use this **unified event** plugin to applications that easily and seamlessly | ||
support mobile (touch) **and** desktop (mouse) environments. | ||
The plugin recognizes mouse, keyboard, and touch motions that have | ||
identical *intent* and publishes a single **unified event** for each. For example, a long-press | ||
*intent* on a desktop is expressed by a *motion* where a user clicks on the LMB for over | ||
0.5s without substantially moving the mouse. A long-press *intent* on a phone or tablet | ||
is expressed by a *motion* where a user touches on a screen for over 0.5s without | ||
substantially moving the touch point. This plugin recognizes the identical *intents* and | ||
publishes the same `uheld` event for either. It does so for many *intents*: | ||
the same **intent** and publishes **unified events** for them. For example, | ||
a long-press **intent** is expressed with a mouse by pressing-and-holding | ||
on the left mouse button for over half a second without substantially moving | ||
the mouse. The same **intent** on a touch device is expressed by placing a | ||
finger on the screen for over half a second without substantially moving the | ||
finger. This pugin recognizes both **motions** as having the same **intent** | ||
and publishes a single `uheld` event for either. | ||
- click (tap) | ||
- long-press (long-tap) | ||
- drag (swipe) | ||
- long-press-drag (long-press-swipe) | ||
- zoom (pinch-to-zoom) | ||
Here are the full list of **intents** supported by this **unified event** | ||
plugin: | ||
This plugin is used in multiple commercial SPAs and is featured in the best-selling book | ||
[Single Page Web Applications - JavaScript end-to-end][1], also [available on Amazon][2]. | ||
- `utap` - Mouse-click (mouse) / Finger tap (touch) | ||
- `uheld` - Long-mouse-press / Finger-press-and-hold | ||
- `udrag` - Mouse-click-and-drag / Finger Swipe | ||
- `uhelddrag` - Long-mouse-press-and-drag / Finger-press-and-hold-and-drag | ||
- zoom - Mouse-click-and-drag-Y + shift / Finger-pinch | ||
Please see the `ue-test.html` file for a demonstration of the different intents. Expected | ||
behavior is expressed in the BR corner of the tiles. If you see any unexpected behavior | ||
while testing motions on your device please file a bug report so I can fix it. | ||
This plugin is used in multiple commercial SPAs and is featured in the | ||
best-selling book [Single Page Web Applications - JavaScript end-to-end][1], | ||
also [available on Amazon][2]. | ||
This plugin is designed to work with jQuery 1.7.0+, and has been tested on most jQuery | ||
versions through 2.1.4. | ||
Please see the `ue-test.html` file for a demonstration of the different intents. | ||
Expected behavior is expressed in the BR corner of the tiles. If you see any | ||
unexpected behavior while testing motions on your device please file a bug report | ||
so we can fix it! | ||
## Browser Support | ||
This plugin works with the latest versions of popular browsers: | ||
This plugin works with jQuery 1.7.0+, and has been tested on most jQuery | ||
versions through 3.0.0. It works with the latest versions of popular browsers: | ||
Chrome 15+, Firefox 23+, Safari 5+, and IE 9+. IE9 requires edge settings: | ||
@@ -83,3 +87,3 @@ | ||
### The click intent | ||
A click *intent* results in a `utap` event. | ||
A click **intent** results in a `utap` event. | ||
- The *Desktop* motion is *Left Mouse Button [LMB] down-up* | ||
@@ -97,3 +101,3 @@ where the mouse-down time is less than the tap tolerance and | ||
### The long-press intent | ||
A long-press *intent* results in a `uheld` event. | ||
A long-press **intent** results in a `uheld` event. | ||
- The *Desktop* motion is *Left Mouse Button [LMB] down-up* | ||
@@ -107,3 +111,3 @@ where the mouse-down time exceeds the long-press tolerance and | ||
### The drag intent | ||
A drag *intent* results in a single `udragstart` event, one or more | ||
A drag **intent** results in a single `udragstart` event, one or more | ||
`udragmove` events, and a final `udragend` event. | ||
@@ -114,12 +118,28 @@ - The *Desktop* motion is *LMB down - mouse-move - LMB up* | ||
- The *Touch* is *touchstart-move-end*, where | ||
the touch time is exceeds the tap tolerance and | ||
the location movement is less than the drag tolerance. | ||
the touch time exceeds drag tolerance, | ||
Event order: | ||
- `udragstart` - fires at the start of a drag (LMB down or finger press where motion has moved out of the drag radius) | ||
- `udragmove` - fires each time the mouse or finger moves | ||
- `udragend` - fires at the end of a drag (LMB up or finger release) | ||
The event order is as follows: | ||
- `udragstart` - fires at the start of a drag | ||
- `udragmove` - fires each time the pointer moves | ||
- `udragend` - fires at the end of a drag | ||
### The held-drag intent | ||
The held-drag **intent** results in a single `uheldstart` event, one or more | ||
`uheldmove` events, and a final `uheldend` event. | ||
- The *Desktop* motion is *LMB down+hold - mouse-move - LMB up* | ||
where the mouse-down time exceeds the held tolerance and the | ||
mouse has stayed within the drag tolerance, after which | ||
the location movement is greater than the drag tolerance. | ||
- The *Touch* is *touchstart+hold-move-end*, where | ||
the touch time exceeds the held tolerance and the touch as | ||
stayed within the drag tolerance, after which the touch | ||
location is greater than the the drag tolerance. | ||
The event order is as follows: | ||
- `uheldstart` - fires at the start of a held-drag | ||
- `uheldmove` - fires each time the pointer moves | ||
- `uheldend` - fires at the end of a held-drag | ||
### The zoom intent | ||
A zoom *intent* results in a single `uzoomstart` event, one or more | ||
A zoom **intent** results in a single `uzoomstart` event, one or more | ||
`uzoommove` events, and a final `uzoomend` event. | ||
@@ -130,5 +150,5 @@ | ||
the location movement is greater than the drag tolerance. | ||
- The *Touch* motion is *two-point-touch - point-move - two-point-release*. | ||
- The *Touch* motion is *two-point-touch - pinch - two-point-release*. | ||
Event order: | ||
The event order is as follows: | ||
- `uzoomstart` - fires at the start of zoom | ||
@@ -191,6 +211,10 @@ - `uzoommove` - fires as zoom amount changes | ||
### Version 1.2.0-4 | ||
- Changed default option key "ignore\_class" to "ignore\_select". | ||
### Version 1.3.0 | ||
- Removed all references to `console` object | ||
- Changed deprecated `bind` and `unbind` to `on` and `off` | ||
### Version 1.2.0-5 | ||
- Changed default option key `ignore_class` to `ignore_select` | ||
- The value is now "" instead of ":input" | ||
- Updated README and published to npm (1.2.4) | ||
- Updated README and published to npm (1.2.5) | ||
@@ -197,0 +221,0 @@ ### Version 1.1.9 |
Sorry, the diff of this file is not supported yet
51656
268