Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added slight delay before application of hover/down classes on touch …

…devices, to prevent unintentional hover-ish behavior when the user intent is to scroll.
  • Loading branch information...
commit 171be28a220d8204e4e244d7ba5fa9f4ce42d16b 1 parent bb2a578
@Wilto Wilto authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 js/jquery.mobile.buttonMarkup.js
View
14 js/jquery.mobile.buttonMarkup.js
@@ -128,6 +128,8 @@ function closestEnabledButton( element ) {
}
var attachEvents = function() {
+ var hoverDelay = 200,
+ hov, foc;
$( document ).bind( {
"vmousedown": function( event ) {
var btn = closestEnabledButton( event.target ),
@@ -136,7 +138,9 @@ var attachEvents = function() {
if ( btn ) {
$btn = $( btn );
theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
- $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
+ hov = setTimeout(function() {
+ $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
+ }, hoverDelay );
}
},
"vmousecancel vmouseup": function( event ) {
@@ -156,17 +160,21 @@ var attachEvents = function() {
if ( btn ) {
$btn = $( btn );
theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
- $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
+ foc = setTimeout(function() {
+ $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
+ }, hoverDelay );
}
},
"vmouseout blur scrollstart": function( event ) {
var btn = closestEnabledButton( event.target ),
$btn, theme;
-
if ( btn ) {
$btn = $( btn );
theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
$btn.removeClass( "ui-btn-hover-" + theme + " ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
+
+ hov && clearTimeout( hov );
+ foc && clearTimeout( foc );
}
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.