There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.
Types
Accordion
A standard accordion
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.
A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.
Styled
A styled accordion adds basic formatting
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.
Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.
A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.
Variations
Fluid
An accordion can take up the width of its container
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.
Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.
A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.
Inverted
An accordion can be formatted to appear on dark backgrounds
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.
Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.
A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.
Examples
Nested Accordions
An accordion can have multiple levels of nested content. This content can either be in a nested accordion
or simply another level of title
and content
Level 1A Contents
Welcome to level 2
Level 2A Contents
Changing Trigger
An accordion normally triggers when its title is clicked. However you can change the trigger selector to specify an element inside a title to use as an activator
A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.
There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.
Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.
A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.
Form Fields
An accordion can be used anywhere where content can be shown or hidden. For example, to show optional form fields.
Accordion Menu
An accordion can be used to create content drawers inside a menu
Initializing
Initializing an accordion
Accordion is initialized on pre-existing markup
AJAX Content
Accordions use DOM Mutation Observers and delegated events to allow for easy compataibility with AJAX content, or content added after initialization.
If the DOM tree changes the module will automatically call module.refresh
and update the selector cache. Because events are bound on the parent module using delegated events, events will automatically fire on content added after initialization.
If you change other attributes of the module without DOM insertion and need to update the cache you can do so by calling this module's refresh
behavior.
Behaviors
Behaviors are short english phrases used for accessing specific functionality in
Behaviors are accessible with javascript using the syntax:
open (index) | Opens accordion content at index |
close others | Closes accordion content that are not active |
close (index) | Closes accordion content at index |
toggle (index) | Toggles accordion content at index |
Accordion
Behavior
Default | Description | |
---|---|---|
exclusive | true | Only allow one section open at a time |
animateChildren | true | Whether child content opacity should be animated (may cause performance issues with many child elements) |
close nested | true | Close open nested accordion content when an element closes |
collapsible | true | Allow active sections to collapse |
duration | 500 | Duration in ms of opening animation |
easing | easeInOutQuint | Easing of opening animation. EaseInOutQuint is included with accordion, for additional options you must include easing equations. |
Callbacks
Context | Description | |
---|---|---|
onOpen | active content | Callback on element open |
onClose | active content | Callback on element close |
onChange | active content | Callback on element open or close |
Module
These settings are native to all modules, and define how the component ties content to DOM attributes, and debugging settings for the module.
Default | Description | |
---|---|---|
name | Accordion | Name used in log statements |
namespace | accordion | Event namespace. Makes sure module teardown does not effect other events attached to an element. |
selector |
selector : {
accordion : '.accordion',
title : '.title',
content : '.content'
}
|
Selectors used to find parts of a module |
className |
className : {
active : 'active'
}
|
Class names used to determine element state |
debug | false | Debug output to console |
performance | true | Show console.table output with performance metrics |
verbose | false | Debug output includes all internal behaviors |
errors |
error : {
method : 'The method you called is not defined.'
}
|