Giter VIP home page Giter VIP logo

meny's Introduction

Meny

A three dimensional and space effecient menu. Meny works best in browsers with support for CSS 3D transforms, although it falls back on 2D animation for older browsers. Supports touch events for mobile devices.

Check out the demo page.

Instructions

1. Download

Add meny.min.js to your project. The meny.min.js file is the only thing required, but you could optionally clone the repository if you want to get the default styles.

2. Markup

Meny requires two HTML elements to work: a menu and the page contents. The class names are not used by the library so chose anything you want.

<body>
  <div class="meny">
    <!-- your menu items -->
  </div>
  <div class="contents">
    <!-- your page contents -->
  </div>
</body>

Some rules, notes and best practices to keep in mind in terms of markup and styling:

  • The menu and contents should have the same parent element.
  • The background which appears behind the contents when Meny is open is not added by the library. You need to set your desired background to the parent element. The default style can be found in demo.css.
  • The arrow which appears when Meny is closed is also not added by the library, if you want it you can easily copy the styles from the demo.css.
  • The menu container will be automatically resized by the library according to configuration options.
  • Meny works on scrolling pages as the menu itself is fixed.

3. Initialize

Next you need create an instance of Meny and tell it which HTML elements to use. This should be done after the meny.min.js is included on your page. Example using the HTML above:

var meny = Meny.create({
	// The element that will be animated in from off screen
	menuElement: document.querySelector( '.meny' ),

	// The contents that gets pushed aside while Meny is active
	contentsElement: document.querySelector( '.contents' ),

	// The alignment of the menu (top/right/bottom/left)
	position: 'left',

	// The height of the menu (when using top/bottom position)
	height: 200,

	// The width of the menu (when using left/right position)
	width: 260
});

4. API & Events

A few handy methods API methods are included, you call these on the instance returned by Meny.create (see above).

meny.open();

meny.close();

meny.isOpen(); // true/false

The wrapper element (parent of the menu and contents) is decorated with classes based on its state:

.meny-active
.meny-top
.meny-right
.meny-bottom
.meny-left

Instances of Meny dispatch events to notify you of their state:

var meny = Meny.create( ... ) // see 3. Initialize

meny.addEventListener( 'open', function() {

	// do something on open

} );

meny.addEventListener( 'close', function() {

	// do something on close

} );

History

1.1

  • Instances of Meny now dispatch 'open'/'close' events

1.0

  • 2D animation fallback (works in IE8+)

0.9

  • Rewrote the JavaScript
  • All core styles/transforms are set via JavaScript
  • Made many options available at initialization
  • New JavaScript fallback using internal animation method

0.3

  • Fallback mode that doesn't rely on transforms

0.2

  • Cleaned up CSS
  • Fix bug where original events for taps on anchors were blocked
  • It's now possible to reach the meny via tapping as well as swiping

0.1

  • Initial release

License

MIT licensed

Copyright (C) 2012 Hakim El Hattab, http://hakim.se

meny's People

Contributors

hakimel avatar

Watchers

Michael jentsch avatar James Cloos avatar  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.