Resizable Widgetversion added: 1.0
Description: Change the size of an element using the mouse.
Options
alsoResizeType: Selector or jQuery or Element
Default:
false
One or more elements to resize synchronously with the resizable element.
animateDurationType: Number or String
Default:
"slow"
How long to animate when using the
Multiple types supported:animate
option.- Number: Duration in milliseconds.
-
String: A named duration, such as
"slow"
or"fast"
.
aspectRatioType: Boolean or Number
Default:
false
Whether the element should be constrained to a specific aspect ratio.
Multiple types supported:-
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.
autoHideType: Boolean
Default:
false
Whether the handles should hide when the user is not hovering over the element.
cancelType: Selector
Default:
"input,textarea,button,select,option"
Prevents resizing from starting on specified elements.
containmentType: Selector or Element or String
Default:
false
Constrains resizing to within the bounds of the specified element or region.
Multiple types supported:- 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"
.
delayType: Number
Default:
0
Tolerance, in milliseconds, for when resizing should start. If specified, resizing will not start until after mouse is moved beyond duration. This can help prevent unintended resizing when clicking on an element.
distanceType: Number
Default:
1
Tolerance, in pixels, for when resizing should start. If specified, resizing will not start until after mouse is moved beyond distance. This can help prevent unintended resizing when clicking on an element.
ghostType: Boolean
Default:
false
If set to
true
, a semi-transparent helper element is shown for resizing.gridType: Array
Default:
false
Snaps the resizing element to a grid, every x and y pixels. Array values:
[ x, y ]
.handlesType: String or Object
Default:
"e, s, se"
Which handles can be used for resizing.
Multiple types supported:- 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.
helperType: String
Default:
false
A class name that will be added to a proxy element to outline the resize during the drag of the resize handle. Once the resize is complete, the original element is sized.
maxHeightType: Number
Default:
null
The maximum height the resizable should be allowed to resize to.
Methods
destroy()
Removes the resizable functionality completely. This will return the element back to its pre-init state.
disable()
Disables the resizable.
enable()
Enables the resizable.
option( optionName ) Returns: Object
Gets the value currently associated with the specified
optionName
.-
optionNameType: StringThe name of the option to get.
option() Returns: PlainObject
Gets an object containing key/value pairs representing the current resizable options hash.
option( optionName, value )
Sets the value of the resizable option associated with the specified
optionName
.option( options )
Sets one or more options for the resizable.
-
optionsType: ObjectA map of option-value pairs to set.
widget() Returns: jQuery
Returns a
jQuery
object containing the resizable element.
Events
resize( event, ui )
This event is triggered during the resize, on the drag of the resize handler.
-
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 }
-
start( event, ui )
This event is triggered at the start of a resize operation.
-
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 }
-
stop( event, ui )
This event is triggered at the end of a resize operation.
-
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 }
-
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.
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 > |