6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
<link rel="stylesheet" href="../assets/css/main.css">
8
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
<script src="../../build/yui/yui-min.js"></script>
17
<a href="#toc" class="jump">Jump to Table of Contents</a>
21
<div id="main" class="yui3-u">
22
<div class="content"><div class="intro">
23
<p>The Resize Utility allows you to make an HTML element resizable.</p>
26
<h2 id="getting-started">Getting Started</h2>
29
To include the source files for Resize and its dependencies, first load
30
the YUI seed file if you haven't already loaded it.
33
<pre class="code prettyprint"><script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script></pre>
37
Next, create a new YUI instance for your application and populate it with the
38
modules you need by specifying them as arguments to the <code>YUI().use()</code> method.
39
YUI will automatically load any dependencies required by the modules you
43
<pre class="code prettyprint">// Create a new YUI instance and populate it with the required modules.
44
YUI().use('resize', 'resize-plugin', function (Y) {
45
// Resize is available and ready for use. Add implementation
46
// code here.
51
For more information on creating YUI instances and on the
52
<a href="http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_use"><code>use()</code> method</a>, see the
53
documentation for the <a href="../yui/index.html">YUI Global object</a>.
59
<h2 id="simple">Simple Resize</h2>
60
<p>You can create a simple Resize instance by including the <code>resize</code> module or <code>base-resize</code> submodule and using the following code:</p>
62
<pre class="code prettyprint">YUI().use('resize', function(Y) {
63
var resize = new Y.Resize({
64
//Selector of the node to resize
65
node: '#demo'
70
<h2 id="events">Events</h2>
72
<p>Resize provides useful events to allow the implementer to control the end-user experience.</p>
86
<td><code>resize:start</code></td>
90
<td>Handles the resize start event. Fired when the user begins dragging a handle.</td>
93
<td><code>resize:resize</code></td>
97
<td>Handles the resize event. Fired with every native <code>mousemove</code> event when the handle is being dragged; this could be as often as once for every pixel of movement.</td>
100
<td><code>resize:align</code></td>
104
<td>Handles the resize align event.</td>
107
<td><code>resize:end</code></td>
111
<td>Handles the resize end event. Fired when the user releases the handle from the drag operation.</td>
114
<td><code>resize:mouseUp</code></td>
118
<td>Handles the resize <code>mouseup</code> event. Fired when a <code>mouseup</code> event happens on a handle.</td>
123
<h2 id="modules">Module Descriptions</h2>
125
<p>Resize for YUI 3 has been broken up into several modules to allow you, as the implementer, to target the specific functionality you want — and omit the functionality you're not using.</p>
135
<td nowrap="nowrap"><code>resize-base</code></td>
136
<td>This is the base Resize class; use this submodule for your simplest use case, where constraints, ratios, and proxies are not required.</td>
139
<td nowrap="nowrap"><code>resize-constrain</code></td>
140
<td>Adds constraining & ratio support.</td>
143
<td nowrap="nowrap"><code>resize-proxy</code></td>
144
<td>Adds proxy support, via <code>dd-proxy</code>.</td>
149
<h2 id="resize-plugins">Resize Plugin for Widgets</h2>
151
<p>Along with the standalone utility, a Resize plugin is available and can be plugged into Y.Node or Y.Widget instances. The plugin can be created by adding <code>resize-plugin</code> in your use statement, and then plugging in <code>Y.Plugin.Resize</code>.</p>
153
<pre class="code prettyprint">YUI().use('overlay', 'resize-plugin', function(Y) {
154
var overlay = new Y.Overlay({
155
width: "200px",
156
height: "300px",
157
srcNode: "#overlay",
158
visible: "true",
159
centered: "true"
161
//Plug in the resizability plugin
162
overlay.plug(Y.Plugin.Resize);
166
<h3 id="listening-to-events-on-a-widget">Listening to events on a widget</h3>
167
<p>With the resize plugin being plugged into a Y.Widget instance, resize events can be listened to under the <code>resize</code> namespace. The resize plugin will automatically change <code>width</code> and <code>height</code> attributes on the widget (and the <code>x</code> , <code>y</code> attributes if your widget uses <code>Y.WidgetPosition</code>).</p>
169
<pre class="code prettyprint">YUI().use('overlay', 'resize-plugin', function(Y) {
170
overlay.plug(Y.Plugin.Resize);
173
overlay.resize.on('resize:resize', function(event) {
174
//this function will be called on resize.
182
<div id="sidebar" class="yui3-u">
184
<div id="toc" class="sidebox">
186
<h2 class="no-toc">Table of Contents</h2>
192
<a href="#getting-started">Getting Started</a>
195
<a href="#simple">Simple Resize</a>
198
<a href="#events">Events</a>
201
<a href="#modules">Module Descriptions</a>
204
<a href="#resize-plugins">Resize Plugin for Widgets</a>
207
<a href="#listening-to-events-on-a-widget">Listening to events on a widget</a>
217
<div class="sidebox">
219
<h2 class="no-toc">Examples</h2>
223
<ul class="examples">
226
<li data-description="Resize a node.">
227
<a href="simple-resize.html">Simple Resize</a>
232
<li data-description="A simple resize implementation that utilizes the ResizeConstrained plugin to set min/max dimensions and to lock in the resized element's aspect ratio.">
233
<a href="constrain-resize.html">Constrain a Resize</a>
238
<li data-description="This example shows an 8-way image resize, providing the CSS needed for a common image-resize visual treatment.">
239
<a href="image-resize.html">8-way Image Resize</a>
244
<li data-description="Plugs a widget with resize functionality.">
245
<a href="simple-resize-plugin.html">Widget with simple Resize Plugin</a>
250
<li data-description="Plugs a widget with resize functionality, and implements ResizeConstrained">
251
<a href="constrain-resize-plugin.html">Widget with Resize Plugin under constraints</a>
265
<script src="../assets/vendor/prettify/prettify-min.js"></script>
266
<script>prettyPrint();</script>