JAVASCRIPT
Stacking items in columns
All samples are using Ink.requireModules
, please read how to use it at Ink.requireModules section
This module combines several stacks of items together, in smaller screen sizes.
The purpose is to have several stacks of items which may have different heights and as such cannot be used because of float: left
quirks.
For example, when you have three different columns of information:
[col. A: 1] [col. B: 1] [col. C: 1]
[col. B: 2] [col. C: 2] [col. C: 2]
and the screen resizes and you need a layout of 2 columns, Stacker reorders the stacks so that you get:
[col. A: 1] [col. B: 1]
[col. C: 1] [col. A: 2]
[col. B: 2] [col. C: 2]
Note: If you just want to use a different amount of columns for your items in several viewports, but these items are guaranteed to have a fixed height, don't use this module. Use the small-*
, medium-*
and large-*
classes instead.
Method name | Description |
---|---|
new Stacker_1([container], [options]) | Constructor |
.addItem(item) | Adds an item to the end of your stacks. |
.reloadItems() | Updates the layout of your items. |
container
Element which contains the stacks (identified by the options.column selector)options
Options object.options.column
Selector for the the columns inside the container element. Defaults to '.stacker-column'.options.item
Selector for the items in your stack. Defaults to '.stacker-item'.options.customBreakPoints
Options for each breakpoint name. Use this if you have more breakpoints than Ink by default (`large`, `medium`, `small`)options.customBreakpoints.BREAKPOINT_NAME
Custom breakpoints object.options.customBreakpoints.BREAKPOINT_NAME.max
Maximum screen size as seen in your media queryoptions.customBreakpoints.BREAKPOINT_NAME.min
Minimum screen size as seen in your media queryoptions.customBreakpoints.BREAKPOINT_NAME.cols
Column count for this size.options.largeMax
Upper bound of `large` breakpointoptions.largeMin
Lower bound of `large` breakpoint. Defaults to 961.options.mediumMax
Upper bound of `medium` breakpoint. Defaults to 960.options.mediumMin
Lower bound of `medium` breakpoint. Defaults to 651.options.smallMax
Upper bound of `small` breakpoint. Defaults to 650.options.smallMin
Lower bound of `small` breakpointoptions.largeCols
Number of columns in the `large` viewport. Defaults to 3.options.mediumCols
Number of columns in the `medium` viewport. Defaults to 2.options.smallCols
Number of columns in the `small` viewport. Defaults to 1.options.isOrdered
When false, doesn't reorder stacks when combining them.options.onRunCallback
Called when instantiated.options.onResizeCallback
Called when the window resizes.options.onAPIReloadCallback
Called when the reload function executes.The below stacks are reorganized into a smaller number of stacks as the viewport gets smaller. The example also shows how you can add more elements to the stack.
Code
Adds an item to the end of your stacks.
Call reloadItems()
when you are done adding items.
item
ElementUpdates the layout of your items.
Call this method after adding items or changing their dimensions. This method is automatically called when the window resizes.