Custom tiles layout library with built-in drag'n'drop support and CSS3 animations.
See the example.
We have a grid with tile elements of various sizes.
Those tiles are "sortable" by the user.
The grid has the following custom layout algorithm:
- Split the container element into cells.
- Split the layout into rows.
- Layout the given tiles inside the row in top-right direction.
- If tile cannot be placed in a row - go to the next row (presume the initial tiles order)
We have 3 predefined (hardcoded) tile sizes:
pin
- 1x1 tileapp
- 2x2 tilefeed
- 3x2 tile
Currently the library determines the width of the grid automatically based on the container DOM element width.
The height of each layout row equals 2 grid cells by default.
The number of rows is unlimited (rows added on demand during the layout phase).
- Install Bower
Runnpm install -g bower
in terminal - Install the component using:
Runbower install yetu/pocketry
in terminal
and then add the script to your page:
<script src="bower_components/pocketry/dist/pocketry.min.js"></script>
The current implementation assumes that you have tile elements rendered in DOM before you init the library.
var grid = new Pocketry('.tiles', 2);
Creates the whole grid with layout rules and drag'n'drop feature in the specified container element.
The selector of the element which will be turned into the grid.
The height of each layout row.
The size of the grid cell in pixels.
options.filterClass (default= 'is-hidden')
All DOM elements within the container, which have the specified class, will not be turned into tiles.
Each tile is represented by a single DOM element.
This element can have these attributes:
data-type
- the type of the tile (pin
,feed
orapp
)data-freezed
- the element cannot be moved by user interaction
The grid instance will fire some events during its lifetime.
You can add listeners using the code:
grid.subscribe(eventName, fn);
This event is triggered when the grid relayout has happened.
The list of all available tile types, which can be used as data-type
attributes.
The model of the current layout.
- install Bower
- install Gulp
npm install -g gulp
bower install
downloads third-party components- Run
gulp tdd
to start watching files and executing tests - open
example/index.html
in a reasonably modern browser
gulp dist
creates release files in./dist
Note: in this case the package will not be checked in.
gulp patch
makes v0.1.0 → v0.1.1gulp minor
makes v0.1.1 → v0.2.0gulp major
makes v0.2.0 → v1.0.0
Note: All this commands will commit & push the changes to master
!