Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A jQuery plugin to create a dynamic, multi-column layout.

License

NotificationsYou must be signed in to change notification settings

germanysbestkeptsecret/Wookmark-jQuery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Join the chat at https://gitter.im/germanysbestkeptsecret/Wookmark-jQueryRead the docsBuild Status

Wookmark

This is a plugin for laying out a dynamic grid of elements.

See thedocumentation page for examples.

The repository also includes many functional examples. All images used in the example are copyrightedby their respective owners and only included for showcasing plugin functionality.

Do you like this project?Buy us a beer

How to make the examples work

First download or clone this repository.Because we use thebower package manager forjQuery and other libraries you currently have toto installbowerfirst.After that you can runbower install and all necessary libraries for the examples will be installed.

We will provide a special download in the future which contains all necessary packages.

Further documentation

We are currently creating a new and better documentation atreadthedocs.Its automatically created by the sources in thedoc directory.

The documentation can be rendered locally by installingsphinx andsphinx-autobuild and runningsphinx-autobuild . _build in thedoc directory.

Upgrading to version 2.0

Since version 2.0 of Wookmark, the plugin doesn't depend on jQuery anymore.This allows you to use Wookmark without the overhead of the jQuery library.

Because this meant a big change to the plugin, we also changed a lot in the codeand tried to make it easier to use. The way you initialize the plugin is now differentand a few options have changend. So if you upgrade you have to adapt your code.See the examples and this readme on how to do this.

Installation

Install with bower

bower install wookmark-jquery

Install with npm

npm install wookmark

jQuery is optional and is used in some of the examples to simplify the code a bit

Required files

Copywookmark.js or the minified versionwookmark.min.js to your javascript folder.There are some styles fortiles-wrap incss/main.css you might want to use.

Usage

The plugin can be intialized in different ways.options are optional.

Default without jQuery

var wookmark = new Wookmark('#myElementContainer'[, options ]);

jQuery call with default settings:

$('#myElementContainer').wookmark(options);

WheremyElementContainer is the class or id of the element or elements wrapping your tiles. A Wookmark instance will be created for each element.

Options

{  align: 'center',  autoResize: false,  comparator: null,  container: $('body'),  direction: undefined,  ignoreInactiveItems: true,  itemWidth: 0,  fillEmptySpace: false,  flexibleWidth: 0,  offset: 2,  onLayoutChanged: undefined,  outerOffset: 0,  possibleFilters: [],  resizeDelay: 50,  verticalOffset: undefined}

See thedocumentation page for details on available options.

itemWidth and flexibleWidth

These values can be given as numbers which will be interpreted as pixels or you can use percentage strings like '20%'.You can also provide a function which should return either a number or a percentage string.WhenflexibleWidth is set anditemWidth is not 0itemWidth used as minimum item width.As example using aflexibleWidth of 40% will result in two columns with 10% space to the sides of the container.

offset, outerOffset and verticalOffset

offset is the horizontal and vertical space between two tiles.outerOffset is the space between the outer tiles and the parent container.verticalOffset is optional and can be set to achieve a vertical offset between two tiles which is different fromoffset.

fillEmptySpace

This creates placeholders at the bottom of each column to create an even layout. Seeexample-placeholder on how to use it.These placeholders use the css classwookmark-placeholder. You can overwrite it in your own css to fit your needs.

ignoreInactiveItems

When set tofalse inactive items will still be shown when filtered. This can be used to fade out filtered items.See the example-filter/fade.html example.

comparator

You can use this option to provide a custom comparator function which the plugin will use to sort the tiles.See example-sort or example-stamp on how to use it.

Refresh trigger

Elements which are hidden have cannot be laid out until they are visible.If you use wookmark on a hidden tab layout will not be immediately performed.When the tab is made visible you can manually refresh Wookmark using a trigger on your container.

wookmark.layout(true);

or

document.getElementById('container').dispatchEvent(new Event('refreshWookmark'));

or with jQuery

$('#container').trigger('refreshWookmark');

Resize trigger

A relayout happens then the viewport is resized, you can also trigger this manually via

window.dispatchEvent(new Event('resize'));

or with jQuery

$(window).trigger('resize');

Filter

You can filter all items of the handler when they have filters specified. Seeexample-filter for details how to do this.The call to filter will also return the resulting list of items.

wookmark.filter([filters=[]][,mode='or'][,dryRun=false]);

If you just want to check if there would be a resulting list of items you can call filter with thedryRun option set totrue.

Annotated code

See ourdocco.

Included examples

Some of the examples need the jQuery or imagesLoaded plugins. Be sure to run bower install to have them working.

example

Is the preferred setup. In this scenario the width and height of all images is set in the HTML img attributes.The grid layout can be performed as soon as the document is rendered, BEFORE images are loaded.

example-load-images

In this example, the width and height of the images is not known. Via Paul Irish's imagesLoaded plugin (slightlymodified by desandro). The grid layout is performed after all images are loaded and their dimensions can beretrieved. This approach is much slower. The imagesLoaded plugin can also be found on github right here:https://github.com/desandro/imagesloaded

example-amd

This example shows how to load and initialize the plugin when usingrequire.js or a different amd loading method.

example-api

This example shows how to load the tile data from a remote api and layout it.

example-endless-scroll

This example shows how to add new tiles at runtime and refresh the layout.

example-filter

This example shows to use thefilter feature of the plugin to show just the tiles the user wants.

example-flexible

This example shows how to use theflexibleWidth option. This option allows your tiles to grow a certain amount, as long as there is room. When using percentage values for the width options you can create a fixed column count layout.

example-lightbox

This example shows you how to include a lightbox.

example-placeholder

This example shows you how to enable placeholders at the bottom of the tile layout to create an even footer.

example-sort

This example shows how thesort feature works. This option allows you to specify a sorting function which will rearrange your tiles.For example you can use it to sort your tiles containing products by price, popularity or name.

FAQ

The tiles overlap after loading.

You should use the 'imagesloaded' plugin. Most the examples in this package include the code how to use it.

The tiles overlap after their height is changed.

Use the 'finished'-callback of your animation/effect to trigger 'refreshWookmark' on the container element supplied to the plugin.

The placeholders at the end of each column have wrong heights or positions.

Set 'position: relative' on your container element and check if there are other elements in the container before your tiles.

My question isn't answered here.

Send us some feedback or create an issue on github.

Mentioned or used by others

Beware: These links lead to sites which are not necessarily related to the authors of the Wookmark plugin so we don't have any control over their content.

Send amessage if you want to be included with your site on this list!

Feedback

Please send code specific questions and feedback toSebastian or contact him ontwitter.

If you have other questions and feedback which is for example related to Wookmark send a mail toChristoph or contact him ontwitter.

Contributing

Contribute!

About

A jQuery plugin to create a dynamic, multi-column layout.

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors23


[8]ページ先頭

©2009-2025 Movatter.jp