Skip to content

Commit bf8d035

Browse files
committed
Update ui/jquery.ui.button.js
Edited default behavior of cancelling button click when the mouse is moved between the mouse-down and mouse-up.  This change allows the  click to be processed when the time between mouse-down and mouse-up is  less than 140ms.
1 parent 78a6354 commit bf8d035

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ui/jquery.ui.button.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
(function( $, undefined ) {
1616

17-
var lastActive, startXPos, startYPos, clickDragged,
17+
var lastActive, startXPos, startYPos, clickDragged, startClickTime
1818
baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
1919
stateClasses = "ui-state-hover ui-state-active ",
2020
typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
@@ -120,9 +120,11 @@ $.widget( "ui.button", {
120120
}
121121
that.refresh();
122122
});
123-
// if mouse moves between mousedown and mouseup (drag) set clickDragged flag
123+
// if a long mouse click (>140ms) moves between mousedown and mouseup (drag) set clickDragged flag
124124
// prevents issue where button state changes but checkbox/radio checked state
125125
// does not in Firefox (see ticket #6970)
126+
127+
126128
this.buttonElement
127129
.bind( "mousedown" + this.eventNamespace, function( event ) {
128130
if ( options.disabled ) {
@@ -131,13 +133,16 @@ $.widget( "ui.button", {
131133
clickDragged = false;
132134
startXPos = event.pageX;
133135
startYPos = event.pageY;
136+
startClickTime = new Date();
134137
})
135138
.bind( "mouseup" + this.eventNamespace, function( event ) {
136139
if ( options.disabled ) {
137140
return;
138141
}
139142
if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
140-
clickDragged = true;
143+
if((new Date() - startClickTime ) > 140){
144+
clickDragged = true;
145+
}
141146
}
142147
});
143148
}

0 commit comments

Comments
 (0)