Interaction: Initiail MSPointer implementation.

This commit is contained in:
Scott González 2012-01-08 22:17:19 -05:00
parent 7332f0e0dd
commit a13894672a

View File

@ -118,6 +118,8 @@ var touchHook = interaction.hooks.touch = {
handle: function( widget ) {
function touchmove( event ) {
// TODO: test non-Apple WebKits to see if they allow
// zooming/scrolling if we don't preventDefault()
var touch = getTouch( event );
if ( !touch ) {
return;
@ -153,4 +155,60 @@ var touchHook = interaction.hooks.touch = {
}
};
// TODO: test mouse, pen
var pointerHook = interaction.hooks.msPointer = {
setup: function( widget, start ) {
widget._bind({
"MSPointerDown": function( event ) {
if ( pointerHook.id ) {
return;
}
pointerHook.id = event.originalEvent.pointerId;
event.originalEvent.preventManipulation();
start( event, {
left: event.pageX,
top: event.pageY
});
}
});
},
handle: function( widget ) {
function pointermove( event ) {
// always prevent manipulation to avoid zooming/scrolling
event.originalEvent.preventManipulation();
if ( event.originalEvent.pointerId !== pointerHook.id ) {
return;
}
widget._interactionMove( event, {
left: event.pageX,
top: event.pageY
});
}
function pointerup( event ) {
if ( event.originalEvent.pointerId !== pointerHook.id ) {
return;
}
widget._interactionStop( event, {
left: event.pageX,
top: event.pageY
});
pointerHook.id = null;
widget.document
.unbind( "MSPointerMove", pointermove )
.unbind( "MSPointerUp", pointerup );
}
widget._bind( widget.document, {
"MSPointerMove": pointermove,
"MSPointerUp": pointerup
});
}
};
})( jQuery );