Giter Site home page Giter Site logo

resizable.js's Introduction

Resizable.js

A JavaScript library allowing the creation of resizable html divs. Try the live demo!

Resizable Example Gif

Setup

Link to both resizable.js and resizable-style.css within the webpage and call: Resizable.initialise(parentId, sizes) Where "parentId" is the element ID of the parent <div> containing your resizable windows and "sizes" is an object literal containing the size values for how much space a child window will initally occupy within its parent (i.e. how far along the resizer line will appear). An empty object {}will cause it to default to equal sizes.

Example:

sizes = {
	"leftChildId": 0.75
}

The above sizing will cause the left child to start at 75% of its parent's width with the right window filling the remaining 25%.

The layout of the resizable windows will be determined by the structure of your HTML and the CSS classes given to the nested <div> elements.

The recognised CSS classes are:

"resizable-top"
"resizable-bottom"
"resizable-left"
"resizable-right"

A parent <div> must be created with a unique ID. To split this parent with a horizontal resizer line, it must contain exactly two child <div> elements with classes of "resizable-top" and "resizable-bottom" respectively. To split the parent with a vertical line, it must contain exactly two child <div> elements with classes of "resizable-left" and "resizable-right" respectively. Any of these child <div> elements can be further split by including two more children within them. Further nesting of <div> elements allows for complex resizable layouts to be created.

To hopefully better demonstrate the correct way to create a layout, the HTML code for the demo page is included below:

<div  id="main">
  <div  class="resizable-left"  id="win1">
    <div  class="resizable-top"  id="win3">
      <div  class="resizable-left"  id="win5">
      </div>
      <div  class="resizable-right"  id="win6">
      </div>
    </div>
    <div  class="resizable-bottom"  id="win4">
    </div>
  </div>
  <div  class="resizable-right"  id="win2">
    <div  class="resizable-top"  win="win7">
      <div  class="resizable-left"  id="win9">
      </div>
      <div  class="resizable-right"  id="win10">
        <div  class="resizable-top"  id="win11">
          <div  class="resizable-left"  id="win13">
          </div>
          <div  class="resizable-right"  id="win14">
          </div>
        </div>
        <div  class="resizable-bottom"  id="win12">
        </div>
      </div>
    </div>
    <div  class="resizable-bottom"  id="win8">
    </div>
  </div>
</div>

It is important to never mix top/bottom and left/right CSS classes within direct children of an element.

The diagram below shows the div ID's of the windows in the demo. They are numbered in the order they're created by the instantiation function. These IDs are for illustrative purposes only, you do not need to give individual IDs to the <div> elements in your page, Window ID Diagram

resizable.js's People

Contributors

tom115x avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.