Home arrow JavaScript arrow Page 4 - Displaying Pinned Handles with Resizable Containers with the Ext JS Library

Using the preserve ratio feature to enhance the behavior of resizable containers - JavaScript

As a web designer, you know that building resizable divs for a web site can be a pretty challenging task, particularly if you’re planning to do this from scratch. There’s no need to reinvent the wheel, though, since there are a few handy JavaScript frameworks available nowadays, such as Ext JS and jQuery, that allow you to create this class of dynamic containers in a truly painless fashion. So if you’re interested in learning how to incorporate dynamic resizing capabilities into certain containers on your web site using the Ext JS package, then this series of articles might be what you’re looking for.

TABLE OF CONTENTS:
  1. Displaying Pinned Handles with Resizable Containers with the Ext JS Library
  2. Review: building simple resizable containers using Ext JS
  3. Adding pinned handles to enhance the visual aspect of resizable containers
  4. Using the preserve ratio feature to enhance the behavior of resizable containers
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
March 30, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
 

Preserving the proportions of a resizable container is a must when it will house images within a web document. Fortunately, it seems that the developers standing behind Ext JS also thought the same way and included in the “Resizable” class a useful parameter called “preservedRatio.” 

By inputting this argument into the class in question, you can create a resizable container that will obviously preserve its width/height ratio, certainly a feature found in most graphic editing applications. 

The following code sample demonstrates the usage of this handy parameter. Have a look at it: 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Example on creating a resizable container with pinned handles (preserved ratio)</title>

<link rel="stylesheet" type="text/css" href="ext-all.css" />

<link rel="stylesheet" type="text/css" href="examples.css" />

<style type="text/css">

body{

padding: 0;

margin: 0;

background: #eee;

}

h1{

font: bold 16pt Arial, Helvetica, sans-serif;

color: #000;

}

p{

font: 9pt Arial, Helvetica, sans-serif;

color: #000;

}

#resizable{

width: 350px;

padding: 10px;

background: #9cf;

}

</style>

<script type="text/javascript" src="ext-base.js"></script>

<script type="text/javascript" src="ext-all.js"></script>

<script type="text/javascript">

// build resizable container when web page is loaded

Ext.onReady(function(){

var resDiv= new Ext.Resizable('resizable', {

wrap: true,

pinned:true,

dynamic: true,

preserveRatio: true,

width: 350,

height: 150,

minWidth: 100,

minHeight: 50

});

});

</script>

</head>

<body>

<h1>Example on creating a resizable container (preserved ratio)</h1>

<div id="resizable">

<p>These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container. These are the contents of a resizable container.</p>

</div>

</body>

</html>

 

See how simple and quick it is to create a resizable div with a preserved ratio? I bet you do! However, don’t take my word for it; try the previous example on your own browser. Believe me, you’ll be very pleased to see how well it works. 

Finally, with this last example I’m concluding this second tutorial of this series on building resizable containers with the Ext JS framework. As usual with many of my articles on web development, feel free to edit all of the code samples developed in this article to help you start incorporating these dynamic elements in your own web site.  

Final thoughts 

In this second part of the series, I explained how to incorporate pinned handles into a targeted container using the Ext JS JavaScript library. In addition, you learned how to preserve the width/height ratio on these dynamic containers. 

In the forthcoming article, I’ll be discussing the creation of containers whose handles are simply…transparent. Pretty interesting, right? If you wish to learn how this can be achieved with Ext JS, then don’t miss the next part!



 
 
>>> More JavaScript Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVASCRIPT ARTICLES

- Javascript for Beginners: An Introduction
- Introduction to JavaScript
- Adding Elements to a Tree with TreeView jQue...
- Using the Persist Argument in a TreeView jQu...
- Using Unique and Toggle in a TreeView jQuery...
- Using Event Delegation for Mouseover Events ...
- Using the Animate Option in a Treeview jQuer...
- Using HTML Lists with Event Delegation in Ja...
- Opened and Closed Branches on a TreeView jQu...
- Mouseover Events and Event Delegation in Jav...
- Creating a TreeView JQuery Hierarchical Navi...
- Event Delegation in JavaScript
- A Look at the New YUI Carousel Control
- Working with Draggable Elements and Transpar...
- Displaying Pinned Handles with Resizable Con...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: