Giter VIP home page Giter VIP logo

akkordion's Introduction

akkordion

VanillaJS Accordion Library

##Why?

  • No flash on page load
  • Initialize by class name and data-* attributes
  • Graceful Degradation for non-transition browsers
  • Could be nested
  • No need jQuery or other dependencies

##Install

bower i akkordion

##Usage

Use .akkordion className for initialize

Add .akkordion-active className to content element to make it active at start. Note: any will be active even with option single:true

P.S.: Recommend do not use vertical paddings on content to prevent flashing on start

<html>
<head>
	<link rel="stylesheet" href="bower_copmonents/akkordion/dist/akkordion.css">
</head>
<body>

	<div class="akkordion" data-akkordion-single="true" data-akkordion-speed="400">
		<div class="akkordion-title">Title</div>
		<div class="akkordion-content akkordion-active"><p>Content</p></div>

		<div class="akkordion-title">Title</div>
		<div class="akkordion-content"><p>Content</p></div>

		...
	</div>

	<script src="bower_copmonents/akkordion/dist/akkordion.js"></script>
</body>
</html>

or you may init custom elements

akkordion(selector, options);

##Effects

Add to root element this classes

  • .akkordion-fade - for opacity animation
  • .akkordion-shiftX - to move 100px horizontally
  • .akkordion-shiftY - to move 30px vertically

Effects are inheritable

##Options

  • options.single - collapse another on open
  • options.speed - animation duration (ms)
  • options.hover - hover delay (ms) or false to disable

##Methods

  • root - HTMLElement initialized by akkordion
  • index is index of valid (with title and content) item. Could be equal -1 for last. Also could be equal one of title or content elements.
  • noAnim - prevent height animation (don't prevent effects)
  • return true if index exists else false
// Open content
akkordion.open(root, index, noAnim);
// Close content
akkordion.close(root, index, noAnim);
// Event listener
akkordion.on(event, callback);

####Events

  • init - with every accordion-root element
  • beforeOpen - prevent openning if return false
  • open
  • afterOpen
  • beforeClose - prevent closing if return false
  • close
  • afterClose

##License

The MIT License (MIT)

Copyright © 2015 Bogdan Chadkin

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.