Stackbox.js

What is it?

Stackbox is a jQuery plugin for creating stackable modal boxes. It's easy to customize using CSS / LESS.

Stackable, you say? Show me!

Sure. Check it out!

So, how do I use it?

1Add some html:

					
<div id="some-element" style="display: none;">
	<div class="stackbox-body">Stackbox example with options</div>
</div>
					
				

2Configure the plugin using HTML5 data-* attributes:

					
<a href="#some-element"
	data-stackbox="true"
	data-stackbox-close-button="true"
	data-stackbox-position="bottom"
	data-stackbox-anim-open="tada slow">Open Stackbox</a>
					
				

3Or use jQuery/JavaScript:

					
$('#some-element').stackbox({
	closeButton: true,
	position: 'bottom',
	animOpen: 'tada slow'
});
					
				

Gimme more examples!

What browsers are supported?

Where's the API? Oh..

NameValuesDefault valueDescriptionExamples
contenthtml | #id stringThe content can be provided either by using plain html, or by using a DOM #id selector string.

Example using html string:

See the Pen Stackbox html content example by Stefan Bruvik (@stebru) on CodePen.

Example using DOM #id selector:

See the Pen Stackbox DOM #id content example by Stefan Bruvik (@stebru) on CodePen.

widthnumber (200) | number + unit ('300px', '300%' etc.) | 'auto'autoSets the width of the entire Stackbox.
maxWidthSee widthfalseMaximum width when width is in percent.
minWidthSee widthfalseMinimum width when width is in percent.
respectBrowserWidthtrue|false100Should the stackbox respect the browser's width?
scrollSpeednumber600Scroll speed in milliseconds.
scrollEasingeaseOutBack|scrollSpeedeaseOutCircScroll easing.
backdroptrue|false|autoautoAdd a backdrop to the Stackbox?
closeOnBackdroptrue|falsetrue
positiontop|bottom|left|right|absolutebottom
marginXnumber15X margin between the Stackbox and the offspring.
marginYnumber5Y margin between the Stackbox and the offspring.
nextTo#id stringnullPlace this stackbox next to another element?
animOpenName of keyframe animationfadeIn
animCloseName of keyframe animationfadeOut
mainWrapperClassstringstackboxes
noscrollClassstringnoscroll
closeButtonIconhtml✖ &#x2716;
spinnerClassstringloading-spinner
autoAdjusttrue|falsetrue
autoScrolltrue|falsetrueScroll to stackbox when opened if outside of (or partically outside of) the window.
queryParamsObject literal {...}nullObject to send as ajax data.
requestTypePOST|GETGET
clonetrue|falsefalse
returnContenttrue|falsetrueIf true, adds extracted dom content back into the dom tree when closing the stackbox.
closeButtontrue|falsetrue
requestFailedhtmlRequest failed. Please try again.
beforeOpenfunctionCallback
afterOpenfunctionCallback
beforeClosefunctionCallback
afterClosefunctionCallback
onErrorfunctionCallback