jQuery UI API - Mouse Interaction
Category
Usage
Description:Basic interaction layer.
Dependencies:
Notes:andjQuery.WidgetSimilarly, Mouse Interaction is not intended for direct use. This is a base layer purely for other widgets to inherit. This page has additions to thejQuery.Widgetdocumentation, but it contains internal methods that cannot be overridden. The public API is_mouseStart()、_mouseDrag()、_mouseStop()and_mouseCapture()。
Quick navigation
| Options | Methods | Events |
|---|---|---|
| Options | Type | Description | Default |
|---|---|---|---|
| cancel | Selector | Prevents interactions from starting on specified elements. Code example: Initialize with the specified
$( ".selector" ).mouse({ cancel: ".title" });
After initialization, get or set the // getter var cancel = $( ".selector" ).mouse( "option", "cancel" ); // setter $( ".selector" ).mouse( "option", "cancel", ".title" ); |
"input, textarea, button, select, option" |
| delay | Number | The time in milliseconds after mouse down until the interaction starts. This option can be used to prevent unwanted interactions when clicking on an element. Code example: Initialize with the specified
$( ".selector" ).mouse({ delay: 300 });
After initialization, get or set the // getter var delay = $( ".selector" ).mouse( "option", "delay" ); // setter $( ".selector" ).mouse( "option", "delay", 300 ); |
0 |
| distance | Number | The distance in pixels the mouse must move after mouse down and before the interaction starts. This option can be used to prevent unwanted interactions when clicking on an element. Code example: Initialize with the specified
$( ".selector" ).mouse({ distance: 10 });
After initialization, get or set the // getter var distance = $( ".selector" ).mouse( "option", "distance" ); // setter $( ".selector" ).mouse( "option", "distance", 10 ); |
1 |
| Methods | Returns | Description |
|---|---|---|
| _mouseCapture() | Boolean | Determines whether the interaction should start based on the event target of the interaction. The default implementation always returnstrue。
Code example: Invoke the _mouseCapture method: $( ".selector" ).mouse( "_mouseCapture" ); |
| _mouseDelayMet() | Boolean | Determinesdelaywhether the option is met for the current interaction.
Code example: Invoke the _mouseDelayMet method: $( ".selector" ).mouse( "_mouseDelayMet" ); |
| _mouseDestroy() | jQuery (plugin only) | Destroys the interaction event handlers. This must be called from the extending widget's_destroy()method.
Code example: Invoke the _mouseDestroy method: $( ".selector" ).mouse( "_mouseDestroy" ); |
| _mouseDistanceMet() | Boolean | Determinesdistancewhether the option is met for the current interaction.
Code example: Invoke the _mouseDistanceMet method: $( ".selector" ).mouse( "_mouseDistanceMet" ); |
| _mouseDown() | jQuery (plugin only) | Handles the start of the interaction. Confirms that the event is associated with the primary mouse button and ensures thatdelayanddistanceis satisfied before the interaction starts. When the interaction is ready to start, it calls the extending widget's_mouseStartmethod.
Code example: Invoke the _mouseDown method: $( ".selector" ).mouse( "_mouseDown" ); |
| _mouseDrag() | jQuery (plugin only) | The extending widget should implement a_mouseDrag()method to handle each move of the interaction. This method receives the mouse event associated with the mouse movement.
Code example: Invoke the _mouseDrag method: $( ".selector" ).mouse( "_mouseDrag" ); |
| _mouseInit() | jQuery (plugin only) | Initializes the interaction event handlers. This must be called from the extending widget's_create()method.
Code example: Invoke the _mouseInit method: $( ".selector" ).mouse( "_mouseInit" ); |
| _mouseMove() | jQuery (plugin only) | Handles each move of the interaction. Calls the extending widget's_mouseDragmethod.
Code example: Invoke the _mouseMove method: $( ".selector" ).mouse( "_mouseMove" ); |
| _mouseStart() | jQuery (plugin only) | The extending widget should implement a_mouseStart()method to handle the start of the interaction. This method receives the mouse event associated with the start of the interaction.
Code example: Invoke the _mouseStart method: $( ".selector" ).mouse( "_mouseStart" ); |
| _mouseStop() | jQuery (plugin only) | The extending widget should implement a_mouseStop()method to handle the end of the interaction. This method receives the mouse event associated with the end of the interaction.
Code example: Invoke the _mouseStop method: $( ".selector" ).mouse( "_mouseStop" ); |
| _mouseUp() | jQuery (plugin only) | Handles the end of the interaction. Calls the extending widget's handler_mouseStopmethod.
Code example: Invoke the _mouseUp method: $( ".selector" ).mouse( "_mouseUp" ); |