mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-01 11:24:42 +00:00
Wait for 750ms before triggering taphold. Trigger tap even if a taphold occurs.
This commit is contained in:
parent
8f7d33f4bd
commit
2ac5e0a755
2 changed files with 14 additions and 12 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue