Wait for 750ms before triggering taphold. Trigger tap even if a taphold occurs.

This commit is contained in:
Scott González 2010-10-12 11:34:31 -04:00
parent 8f7d33f4bd
commit 2ac5e0a755
2 changed files with 14 additions and 12 deletions

View file

@ -60,8 +60,7 @@ $.event.special.tap = {
return;
}
var held = false,
moved = false,
var moved = false,
touching = true,
originalType,
timer;
@ -72,13 +71,12 @@ $.event.special.tap = {
timer = setTimeout(function() {
if ( touching && !moved ) {
held = true;
originalType = event.type;
event.type = "taphold";
$.event.handle.call( thisObject, event );
event.type = originalType;
}
}, 300 );
}, 750 );
$this
.one( touchMoveEvent, moveHandler)
@ -87,7 +85,7 @@ $.event.special.tap = {
clearTimeout( timer );
touching = false;
if ( !held && !moved ) {
if ( !moved ) {
originalType = event.type;
event.type = "tap";
$.event.handle.call( thisObject, event );

View file

@ -6,13 +6,17 @@
<script type="text/javascript" src="../js/all"></script>
<script>
$(function() {
$( "p" ).tap(function() {
var elem = this;
$( elem ).css( "color", "#f00" );
setTimeout(function() {
$( elem ).css( "color", "#000" );
}, 500 );
});
$( "p" )
.tap(function() {
var elem = this;
$( elem ).css( "color", "#f00" );
setTimeout(function() {
$( elem ).css( "color", "#000" );
}, 500 );
})
.taphold(function() {
$( this ).css( "color", "#0f0" );
});
});</script>
</head>
<body>