Resizable Widgetversion added: 1.0
Description: Change the size of an element using the mouse.
The jQuery UI Resizable plugin makes selected elements resizable (meaning they have draggable resize handles). You can specify one or more handles as well as min and max width and height.
Additional Notes:
- This widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS file as a starting point.
Options
alsoResizeType: Selector or jQuery or Element
false
Initialize the resizable with the alsoResize option specified:
$( ".selector" ).resizable({ alsoResize: "#mirror" }); |
Get or set the alsoResize option, after initialization:
// getter var alsoResize = $( ".selector" ).resizable( "option" , "alsoResize" ); // setter $( ".selector" ).resizable( "option" , "alsoResize" , "#mirror" ); |
animateType: Boolean
false
Initialize the resizable with the animate option specified:
$( ".selector" ).resizable({ animate: true }); |
Get or set the animate option, after initialization:
// getter var animate = $( ".selector" ).resizable( "option" , "animate" ); // setter $( ".selector" ).resizable( "option" , "animate" , true ); |
animateDurationType: Number or String
"slow"
animate
option.- Number: Duration in milliseconds.
-
String: A named duration, such as
"slow"
or"fast"
.
Initialize the resizable with the animateDuration option specified:
$( ".selector" ).resizable({ animateDuration: "fast" }); |
Get or set the animateDuration option, after initialization:
// getter var animateDuration = $( ".selector" ).resizable( "option" , "animateDuration" ); // setter $( ".selector" ).resizable( "option" , "animateDuration" , "fast" ); |
animateEasingType: String
"swing"
Initialize the resizable with the animateEasing option specified:
$( ".selector" ).resizable({ animateEasing: "easeOutBounce" }); |
Get or set the animateEasing option, after initialization:
// getter var animateEasing = $( ".selector" ).resizable( "option" , "animateEasing" ); // setter $( ".selector" ).resizable( "option" , "animateEasing" , "easeOutBounce" ); |
aspectRatioType: Boolean or Number
false
-
Boolean: When set to
true
, the element will maintain its original aspect ratio. - Number: Force the element to maintain a specific aspect ratio during resizing.
Initialize the resizable with the aspectRatio option specified:
$( ".selector" ).resizable({ aspectRatio: true }); |
Get or set the aspectRatio option, after initialization:
// getter var aspectRatio = $( ".selector" ).resizable( "option" , "aspectRatio" ); // setter $( ".selector" ).resizable( "option" , "aspectRatio" , true ); |
autoHideType: Boolean
false
Initialize the resizable with the autoHide option specified:
$( ".selector" ).resizable({ autoHide: true }); |
Get or set the autoHide option, after initialization:
// getter var autoHide = $( ".selector" ).resizable( "option" , "autoHide" ); // setter $( ".selector" ).resizable( "option" , "autoHide" , true ); |
cancelType: Selector
"input,textarea,button,select,option"
Initialize the resizable with the cancel option specified:
$( ".selector" ).resizable({ cancel: ".cancel" }); |
Get or set the cancel option, after initialization:
// getter var cancel = $( ".selector" ).resizable( "option" , "cancel" ); // setter $( ".selector" ).resizable( "option" , "cancel" , ".cancel" ); |
containmentType: Selector or Element or String
false
- Selector: The resizable element will be contained to the bounding box of the first element found by the selector. If no element is found, no containment will be set.
- Element: The resizable element will be contained to the bounding box of this element.
-
String: Possible values:
"parent"
and"document"
.
Initialize the resizable with the containment option specified:
$( ".selector" ).resizable({ containment: "parent" }); |
Get or set the containment option, after initialization:
// getter var containment = $( ".selector" ).resizable( "option" , "containment" ); // setter $( ".selector" ).resizable( "option" , "containment" , "parent" ); |
delayType: Number
0
Initialize the resizable with the delay option specified:
$( ".selector" ).resizable({ delay: 150 }); |
Get or set the delay option, after initialization:
// getter var delay = $( ".selector" ).resizable( "option" , "delay" ); // setter $( ".selector" ).resizable( "option" , "delay" , 150 ); |
disabledType: Boolean
false
true
.Initialize the resizable with the disabled option specified:
$( ".selector" ).resizable({ disabled: true }); |
Get or set the disabled option, after initialization:
// getter var disabled = $( ".selector" ).resizable( "option" , "disabled" ); // setter $( ".selector" ).resizable( "option" , "disabled" , true ); |
distanceType: Number
1
Initialize the resizable with the distance option specified:
$( ".selector" ).resizable({ distance: 30 }); |
Get or set the distance option, after initialization:
// getter var distance = $( ".selector" ).resizable( "option" , "distance" ); // setter $( ".selector" ).resizable( "option" , "distance" , 30 ); |
ghostType: Boolean
false
true
, a semi-transparent helper element is shown for resizing.Initialize the resizable with the ghost option specified:
$( ".selector" ).resizable({ ghost: true }); |
Get or set the ghost option, after initialization:
// getter var ghost = $( ".selector" ).resizable( "option" , "ghost" ); // setter $( ".selector" ).resizable( "option" , "ghost" , true ); |
gridType: Array
false
[ x, y ]
.Initialize the resizable with the grid option specified:
$( ".selector" ).resizable({ grid: [ 20, 10 ] }); |
Get or set the grid option, after initialization:
// getter var grid = $( ".selector" ).resizable( "option" , "grid" ); // setter $( ".selector" ).resizable( "option" , "grid" , [ 20, 10 ] ); |
handlesType: String or Object
"e, s, se"
- String: A comma delimited list of any of the following: n, e, s, w, ne, se, sw, nw, all. The necessary handles will be auto-generated by the plugin.
- Object: The following keys are supported: { n, e, s, w, ne, se, sw, nw }. The value of any specified should be a jQuery selector matching the child element of the resizable to use as that handle. If the handle is not a child of the resizable, you can pass in the DOMElement or a valid jQuery object directly.
Initialize the resizable with the handles option specified:
$( ".selector" ).resizable({ handles: "n, e, s, w" }); |
Get or set the handles option, after initialization:
// getter var handles = $( ".selector" ).resizable( "option" , "handles" ); // setter $( ".selector" ).resizable( "option" , "handles" , "n, e, s, w" ); |
helperType: String
false
Initialize the resizable with the helper option specified:
$( ".selector" ).resizable({ helper: "resizable-helper" }); |
Get or set the helper option, after initialization:
// getter var helper = $( ".selector" ).resizable( "option" , "helper" ); // setter $( ".selector" ).resizable( "option" , "helper" , "resizable-helper" ); |
maxHeightType: Number
null
Initialize the resizable with the maxHeight option specified:
$( ".selector" ).resizable({ maxHeight: 300 }); |
Get or set the maxHeight option, after initialization:
// getter var maxHeight = $( ".selector" ).resizable( "option" , "maxHeight" ); // setter $( ".selector" ).resizable( "option" , "maxHeight" , 300 ); |
maxWidthType: Number
null
Initialize the resizable with the maxWidth option specified:
$( ".selector" ).resizable({ maxWidth: 300 }); |
Get or set the maxWidth option, after initialization:
// getter var maxWidth = $( ".selector" ).resizable( "option" , "maxWidth" ); // setter $( ".selector" ).resizable( "option" , "maxWidth" , 300 ); |
minHeightType: Number
10
Initialize the resizable with the minHeight option specified:
$( ".selector" ).resizable({ minHeight: 150 }); |
Get or set the minHeight option, after initialization:
// getter var minHeight = $( ".selector" ).resizable( "option" , "minHeight" ); // setter $( ".selector" ).resizable( "option" , "minHeight" , 150 ); |
minWidthType: Number
10
Initialize the resizable with the minWidth option specified:
$( ".selector" ).resizable({ minWidth: 150 }); |
Get or set the minWidth option, after initialization:
// getter var minWidth = $( ".selector" ).resizable( "option" , "minWidth" ); // setter $( ".selector" ).resizable( "option" , "minWidth" , 150 ); |
Methods
destroy()
- This method does not accept any arguments.
Invoke the destroy method:
$( ".selector" ).resizable( "destroy" ); |
disable()
- This method does not accept any arguments.
Invoke the disable method:
$( ".selector" ).resizable( "disable" ); |
enable()
- This method does not accept any arguments.
Invoke the enable method:
$( ".selector" ).resizable( "enable" ); |
option( optionName )Returns: Object
optionName
.-
optionNameType: StringThe name of the option to get.
Invoke the method:
var isDisabled = $( ".selector" ).resizable( "option" , "disabled" ); |
option()Returns: PlainObject
- This method does not accept any arguments.
Invoke the method:
var options = $( ".selector" ).resizable( "option" ); |
option( optionName, value )
optionName
.-
optionNameType: StringThe name of the option to set.
-
valueType: ObjectA value to set for the option.
Invoke the method:
$( ".selector" ).resizable( "option" , "disabled" , true ); |
option( options )
-
optionsType: ObjectA map of option-value pairs to set.
Invoke the method:
$( ".selector" ).resizable( "option" , { disabled: true } ); |
widget()Returns: jQuery
jQuery
object containing the resizable element.
- This method does not accept any arguments.
Invoke the widget method:
var widget = $( ".selector" ).resizable( "widget" ); |
Events
create( event, ui )Type: resizecreate
Initialize the resizable with the create callback specified:
$( ".selector" ).resizable({ create: function ( event, ui ) {} }); |
Bind an event listener to the resizecreate event:
$( ".selector" ).on( "resizecreate" , function ( event, ui ) {} ); |
resize( event, ui )Type: resize
-
eventType: Event
-
uiType: Object
-
elementType: jQueryThe jQuery object representing the element to be resized
-
helperType: jQueryThe jQuery object representing the helper that's being resized
-
originalElementType: jQueryThe jQuery object representing the original element before it is wrapped
-
originalPositionType: ObjectThe position represented as
{ left, top }
before the resizable is resized -
originalSizeType: ObjectThe size represented as
{ width, height }
before the resizable is resized -
positionType: ObjectThe current position represented as
{ left, top }
-
sizeType: ObjectThe current size represented as
{ width, height }
-
Initialize the resizable with the resize callback specified:
$( ".selector" ).resizable({ resize: function ( event, ui ) {} }); |
Bind an event listener to the resize event:
$( ".selector" ).on( "resize" , function ( event, ui ) {} ); |
start( event, ui )Type: resizestart
-
eventType: Event
-
uiType: Object
-
elementType: jQueryThe jQuery object representing the element to be resized
-
helperType: jQueryThe jQuery object representing the helper that's being resized
-
originalElementType: jQueryThe jQuery object representing the original element before it is wrapped
-
originalPositionType: ObjectThe position represented as
{ left, top }
before the resizable is resized -
originalSizeType: ObjectThe size represented as
{ width, height }
before the resizable is resized -
positionType: ObjectThe current position represented as
{ left, top }
-
sizeType: ObjectThe current size represented as
{ width, height }
-
Initialize the resizable with the start callback specified:
$( ".selector" ).resizable({ start: function ( event, ui ) {} }); |
Bind an event listener to the resizestart event:
$( ".selector" ).on( "resizestart" , function ( event, ui ) {} ); |
stop( event, ui )Type: resizestop
-
eventType: Event
-
uiType: Object
-
elementType: jQueryThe jQuery object representing the element to be resized
-
helperType: jQueryThe jQuery object representing the helper that's being resized
-
originalElementType: jQueryThe jQuery object representing the original element before it is wrapped
-
originalPositionType: ObjectThe position represented as
{ left, top }
before the resizable is resized -
originalSizeType: ObjectThe size represented as
{ width, height }
before the resizable is resized -
positionType: ObjectThe current position represented as
{ left, top }
-
sizeType: ObjectThe current size represented as
{ width, height }
-
Initialize the resizable with the stop callback specified:
$( ".selector" ).resizable({ stop: function ( event, ui ) {} }); |
Bind an event listener to the resizestop event:
$( ".selector" ).on( "resizestop" , function ( event, ui ) {} ); |
Example:
A simple jQuery UI Resizable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <!doctype html> < html lang = "en" > < head > < meta charset = "utf-8" > < title >resizable demo</ title > < style > #resizable { width: 100px; height: 100px; background: #ccc; } </ style > </ head > < body > < div id = "resizable" ></ div > < script > $( "#resizable" ).resizable(); </ script > </ body > </ html > |