Yahoo! Developer Network Home - Help

YDN Site Search

# YUI Library Examples: Resize Utility (beta): 8-way Element Resize

# Resize Utility (beta): 8-way Element Resize

This example shows how to make an element resizable by all 8 handles.

View example in new window.

## Setting up the element that we are going to resize

We are going to make the element `#yui_img` resizable in all 8 directions.

Note: When you want to resize an element that requires the top and left sides to be positioned, it is best practice to make the element `position: absolute`. Otherwise it will be positioned relative and the outcome will not be what you expected.

#yui_img { position: absolute; top: 20px; left: 20px; } <img src="assets/yui.jpg" id="yui_img" height="166" width="250">

## Creating the resize instance

Since an image cannot have child nodes appended to it, the Resize Utility will auto wrap it with an element that can. See the API docs for more info on the wrap option.

For shorthand, we are using the `handles` type of `All`, which just simply means `t, r, b, l, tr, tl, br, bl`. We are also using the config `knobHandles`, this applies a class to the Resize element and styles all of the handles into the small knobs seen above.

In this instance we have also turned on the convenience option `draggable`, this will allow the element to be dragged.

(function() { var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event; var resize = new YAHOO.util.Resize('yui_img', { handles: 'all', knobHandles: true, height: '166px', width: '250px', proxy: true, draggable: true, animate: true, animateDuration: .75, animateEasing: YAHOO.util.Easing.backBoth }); })();

### Resize Utility (beta) Examples:

- Simple Resize
- Proxy Resize
- Animated Proxy Resize
- 8-way Element Resize
- Ghosting and Custom Proxy Resize
- Custom resizing for the Rich Text Editor
- Split Pane resizing with Grids CSS
- Skinning the Resize Utility
- Layout inside a resizable Panel (included with examples for Layout Manager (beta))
- Creating a Resizable Panel (included with examples for Container Family)
- Complex Application (included with examples for Layout Manager (beta))

### More Resize Utility (beta) Resources:

- User's Guide (external)
- API Documentation
- Cheat Sheet PDF (external)

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings