- 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:
Kin Blas 2011-02-25 22:20:04 -08:00
parent 730dae0fc1
commit 3f627acba8
2 changed files with 15 additions and 7 deletions

View file

@ -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 );
}
});

View file

@ -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();
}