Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/domchristie/drawer

A starting point for building 2-column responsive layouts that implement a smooth (jank free) sliding sidebar
https://github.com/domchristie/drawer

Last synced: 12 days ago
JSON representation

A starting point for building 2-column responsive layouts that implement a smooth (jank free) sliding sidebar

Awesome Lists containing this project

README

        

# Drawer: jank free sliding sidebar layouts

## What?

**Drawer** is a starting point for building 2-column responsive layouts that implement a smooth sliding sidebar (or _drawer_).

The default behaviour is as follows:

**On smaller viewport sizes**: the drawer is hidden by default. When the drawer is shown, the content is shifted to the right, whilst maintaining its width.

**On larger viewport sizes**: the drawer is always shown (toggling makes no difference). Content fills the remaining space.

## Why?

The project was created to fulfil the following requirements:

* It should include **jank free sliding transitions**, by making use of hardware accelerated properties (i.e. CSS transforms).
* It **should not break native scrolling controls**: the main content should be scrollable using page up/down keys, as well as by using the _tap-status-bar-to-return-to-top_ behaviour.
* **Very few (if any) external dependencies**, to keep it lightweight and easy to customise.
* Leave most of the interaction/visual design to the implementer.

There are a few other implementations of the general UI pattern, but it was difficult to find one that fulfilled all of the above.

## Usage

1. Add the following meta viewport tag:


2. Include the `drawer.css` stylesheet
3. Wrap your sidebar content in an element with a class of `drawer`
4. Wrap any content that “butts up” to the drawer in an element with a class of `drawer-butt`. (This will usually be your main content, but it may also be a header, for example. See [simple example](http://domchristie.github.io/drawer/examples/simple.html).)
5. Read the `drawer.css` source code, and customise as you wish.
6. Toggle the drawer by adding/removing the `drawer-open` class to the body element

For example, if you had a toggle element with a `data-drawer-toggle` attribute, you might toggle the drawer with jQuery, as follows:

$(document).on('click touchstart', '[data-drawer-toggle]', function() {
$('body').toggleClass('drawer-open');
});

## Browser Support

Drawer has been designed to work with _modern browers_ i.e. **recent versions** of **Chrome**, **Firefox**, **Safari**, **Opera**, and **Internet Explorer** (although sliding animations will not work in IE9). IE 7/8 users will see the two-column version of the site (toggling will have no effect).

## Examples

* [A basic fixed header and toggle example](http://domchristie.github.io/drawer/examples/simple.html)
* [A responsive navigation bar example](http://domchristie.github.io/drawer/examples/navigation.html)

## Bibliography

Drawer uses ideas from the following resources:

* [Mailchimp Pattern Library](http://ux.mailchimp.com/patterns)
* [Multi-Device Layout Patterns](http://www.lukew.com/ff/entry.asp?1514) by Luke Wroblewski
* [Off Canvas: A Multi-Device Web Layout Pattern](http://jasonweaver.name/lab/offcanvas/) by Jason Weaver
* [Jank Free](http://jankfree.org/)

## Licence

Drawer is copyright © 2013 [Dom Christie](http://domchristie.co.uk) and is released under the MIT licence.