mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-10 09:21:02 +00:00
- Added support for a vmouseevent that is triggered when a touch results in the window scrolling.
- Modified the button markup behavior so that it uses the virtual mouse events and adds the ui-btn-active class on vmousedown, and then removes it on vmousemove or vmouseup.
This commit is contained in:
parent
730dae0fc1
commit
3f627acba8
2 changed files with 15 additions and 7 deletions
|
|
@ -83,21 +83,21 @@ $.fn.buttonMarkup.defaults = {
|
|||
|
||||
var attachEvents = function() {
|
||||
$(".ui-btn:not(.ui-disabled)").live({
|
||||
"touchstart mousedown": function() {
|
||||
"vmousedown": function() {
|
||||
var theme = $(this).attr( "data-theme" );
|
||||
$(this).removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
|
||||
$(this).removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme + " " + $.mobile.activeBtnClass);
|
||||
},
|
||||
"touchmove touchend mouseup": function() {
|
||||
"vmousemove vmouseup": function() {
|
||||
var theme = $(this).attr( "data-theme" );
|
||||
$(this).removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
|
||||
$(this).removeClass( "ui-btn-down-" + theme + " " + $.mobile.activeBtnClass ).addClass( "ui-btn-up-" + theme );
|
||||
},
|
||||
"mouseover focus": function() {
|
||||
"vmouseover focus": function() {
|
||||
var theme = $(this).attr( "data-theme" );
|
||||
$(this).removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
|
||||
},
|
||||
"mouseout blur": function() {
|
||||
"vmouseout blur": function() {
|
||||
var theme = $(this).attr( "data-theme" );
|
||||
$(this).removeClass( "ui-btn-hover-" + theme ).addClass( "ui-btn-up-" + theme );
|
||||
$(this).removeClass( "ui-btn-hover-" + theme + " " + $.mobile.activeBtnClass ).addClass( "ui-btn-up-" + theme );
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,10 @@ function handleTouchStart(event)
|
|||
|
||||
function handleScroll(event)
|
||||
{
|
||||
if (!didScroll){
|
||||
triggerVirtualEvent("vmousecancel", event);
|
||||
}
|
||||
|
||||
didScroll = true;
|
||||
startResetTimer();
|
||||
}
|
||||
|
|
@ -224,10 +228,14 @@ function handleTouchMove(event)
|
|||
{
|
||||
var t = getNativeEvent(event).touches[0];
|
||||
|
||||
var didCancel = didScroll;
|
||||
didScroll = didScroll
|
||||
|| (scrollTopSupported && (startScrollX != window.pageXOffset || startScrollY != window.pageYOffset))
|
||||
|| (Math.abs(t.pageX - startX) > scrollThreshold || Math.abs(t.pageY - startY) > scrollThreshold);
|
||||
|
||||
if (didScroll && !didCancel){
|
||||
triggerVirtualEvent("vmousecancel", event);
|
||||
}
|
||||
triggerVirtualEvent("vmousemove", event);
|
||||
startResetTimer();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue