mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
85 lines
1.7 KiB
JavaScript
85 lines
1.7 KiB
JavaScript
(function( $, undefined ) {
|
|
|
|
var interaction; // = $.ui.interaction
|
|
|
|
$.widget( "ui.interaction", {
|
|
version: "@VERSION",
|
|
_create: function() {
|
|
for ( var hook in interaction.hooks ) {
|
|
interaction.hooks[ hook ].setup( this, this._startProxy( hook ) );
|
|
}
|
|
},
|
|
|
|
_startProxy: function( hook ) {
|
|
var that = this;
|
|
return function( event, position ) {
|
|
that._interactionStart( event, position, hook );
|
|
}
|
|
},
|
|
|
|
_interactionStart: function( event, position, hook ) {
|
|
if ( false !== this._start( event, position ) ) {
|
|
interaction.started = true;
|
|
interaction.hooks[ hook ].handle( this );
|
|
}
|
|
},
|
|
|
|
_interactionMove: function( event, position ) {
|
|
this._move( event, position );
|
|
},
|
|
|
|
_interactionStop: function( event, position ) {
|
|
this._stop( event, position );
|
|
interaction.started = false;
|
|
}
|
|
});
|
|
|
|
interaction = $.ui.interaction;
|
|
$.extend( interaction, {
|
|
started: false,
|
|
hooks: {}
|
|
});
|
|
|
|
interaction.hooks.mouse = {
|
|
setup: function( widget, start ) {
|
|
widget._bind({
|
|
"mousedown": function( event ) {
|
|
if ( event.which === 1 ) {
|
|
event.preventDefault();
|
|
start( event, {
|
|
left: event.pageX,
|
|
top: event.pageY
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
handle: function( widget ) {
|
|
function mousemove( event ) {
|
|
event.preventDefault();
|
|
widget._interactionMove( event, {
|
|
left: event.pageX,
|
|
top: event.pageY
|
|
});
|
|
}
|
|
|
|
function mouseup( event ) {
|
|
widget._interactionStop( event, {
|
|
left: event.pageX,
|
|
top: event.pageY
|
|
});
|
|
widget.document
|
|
.unbind( "mousemove", mousemove )
|
|
.unbind( "mouseup", mouseup );
|
|
}
|
|
|
|
widget._bind( widget.document, {
|
|
"mousemove": mousemove,
|
|
"mouseup": mouseup
|
|
});
|
|
}
|
|
};
|
|
|
|
})( jQuery );
|