Giter Site home page Giter Site logo

maxim-devereaux / resizeable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tom-rawlings/resizable.js

0.0 0.0 0.0 130 KB

A JavaScript library allowing the creation of manually resizeable div elements

License: MIT License

JavaScript 92.56% CSS 2.89% HTML 4.55%

resizeable's Introduction

Resizeable.js

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

Resizeable Example Gif

Setup

Link to both resizeable.js and resizeable-style.css within the webpage and call: Resizeable.initialise(parentId, sizes, resizerThickness) Where "parentId" is the element ID of the parent <div> containing your resizeable 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. The third argument "resizerThickness" allows you to specify how thick the dividing lines will be. This is optional and will default to 4px.

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 resizeable 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:

"resizeable-top"
"resizeable-bottom"
"resizeable-left"
"resizeable-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 "resizeable-top" and "resizeable-bottom" respectively. To split the parent with a vertical line, it must contain exactly two child <div> elements with classes of "resizeable-left" and "resizeable-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 resizeable 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="resizeable-left"  id="win1">
    <div  class="resizeable-top"  id="win3">
      <div  class="resizeable-left"  id="win5">
      </div>
      <div  class="resizeable-right"  id="win6">
      </div>
    </div>
    <div  class="resizeable-bottom"  id="win4">
    </div>
  </div>
  <div  class="resizeable-right"  id="win2">
    <div  class="resizeable-top"  id="win7">
      <div  class="resizeable-left"  id="win9">
      </div>
      <div  class="resizeable-right"  id="win10">
        <div  class="resizeable-top"  id="win11">
          <div  class="resizeable-left"  id="win13">
          </div>
          <div  class="resizeable-right"  id="win14">
          </div>
        </div>
        <div  class="resizeable-bottom"  id="win12">
        </div>
      </div>
    </div>
    <div  class="resizeable-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

resizeable's People

Contributors

maxim-devereaux avatar tom115x avatar tom-rawlings avatar t-rawlings 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.