Settings

Settings object

Gridifier constructor accepts settings object as second parameter, which consist of key-values setting pairs. Most of values represents simple strings or numbers(Core settings), however some values can represent more complex data structure, like function or object with function names/functions pairs.(Api settings)

Core settings
Full list of core settings, which can be passed to Gridifier constructor

var asyncGrid = new Gridifier(grid, {
    // Wide used core settings
    "class": "grid-item", // default - class: "grid-item"
    data: "data-myitem", // default - class: "grid-item"
    query: "> a", // default - class: "grid-item"

    grid: "vertical|horizontal", // default = "vertical"

    prepend: "mirrored|default|reversed", // default = "mirrored"
    append: "default|reversed", // default = "default"

    intersections: true|false, // default = true
    align: "top|bottom|left|right|center", // default = "top(Vertical grid)|left(Horizontal grid)"

    sortDispersion: true|false, // default = false
    loadImages: true|false, // default = false

    toggleTime: 800, // default = 500
    coordsChangeTime: 500, // default = 300

    toggleTiming: "cubic-bezier(0.550, 0.055, 0.675, 0.190)", // default = "ease"
    coordsChangeTiming: "cubic-bezier(0.550, 0.055, 0.675, 0.190)", // default = "ease"

    rotatePerspective: "500px", // default = "200px"
    rotateBackface: true|false, // default = true
    rotateAngles: [-180, -360, 180, 0], // default = [0, -180, 180, 0]

    gridResize: "fit|expand|disabled", // default = "fit"
    gridResizeDelay: 0, // default = 100

    dragifier: true|false|".dragHandler", // default = false
    dragifierMode: "i|d", // default = "i"

    widthPtAs: 0.1, // default = 0
    heightPtAs: 0.1, // default = 0
    widthPxAs: 1, // default = 0
    heightPxAs: 1, // default = 0

    repackSize: 20, // default = gridItems.length

    // Less used core settings
    insertRange: 10000, // default = 3000
    vpResizeDelay: 100, // default = null

    queueSize: 100, // default = 12
    queueDelay: 0, // default = 25
    disableQueueOnDrags: true|false // default = true(dm=i), false(dm=d)
});
        

Let's describe the purpose of each Gridifier core setting and it's available values:

class, data, query
defines grid items selector, default = class: "grid-item"
grid
defines grid type, default = "vertical"

Available values:

prepend
defines type of inserting items in the beginning of the grid, default = "mirrored"

Available values with grid = "vertical":

Available values with grid = "horizontal":

append
defines type of inserting items in the end of the grid, default = "default"

Available values with grid = "vertical":

Available values with grid = "horizontal":

intersections
defines type of items intersection inside grid, default = true

Available values with grid = "vertical":

Available values with grid = "horizontal":

align
defines type of items align with no intersections mode, default = "top(VG)|left(HG)"

Available values with grid = "vertical":

Available values with grid = "horizontal":

Notice.
You can pass only 'align' setting to Gridifier.(This will automatically set 'intersections' option to false value)

sortDispersion
defines items insertion sorting dispersion mode, default = false

Normal order rules on vertical grid appends:

Normal order rules on vertical grid prepends:

Normal order rules on horizontal grid appends:

Normal order rules on horizontal grid prepends:

Notice.
Mirrored prepends internally are using appends, so append order rules will be applied.

Available values:

loadImages
specifies if Gridifier should wait while all images from all inserted items are loaded, default = false
toggleTime
defines grid items show/hide animation duration in 'ms', default = 500
coordsChangeTime
defines grid items position change animation duration in 'ms', default = 300
toggleTiming
defines grid items show/hide animation CSS3 transition timing, default = 'ease'
coordsChangeTiming
defines grid items position change animation CSS3 transition timing, default = 'ease'
rotatePerspective
sets the CSS3 perspective from where rotated element is viewed, default = "200px"
rotateBackface
sets if the backface of rotated item should be visible, default = true
rotateAngles
sets rotate animation init and target angles, default = [0, -180, 180, 0]

Angles array values:

gridResize
sets grid sizes update type after item inserts/disconnects and grid resizes, default = "fit"

Available values with grid = "vertical":

Available values with grid = "horizontal":

gridResizeDelay
sets ms timeout, after which grid sizes updates will be applied, default = 100

Notice.
Gridifier is applying grid sizes changes after timeout, which is being fired after specified ms count. If multiple items are inserted/disconnected, this timeout will be rescheduled.

This is required because it is too expensive to update grid sizes after each insert/disconnect on grids with large items count. (Browser reflow operations will slow down performance on touch devices)

On small grids you can set this value to 20 or 0, if delay between inserts and grid sizes changes is noticeable.

dragifier
specifies, if item drags should be enabled, default = false

Available values:

dragifierMode
specifies algorithm, which is used by dragifier kernel, default = "i"

Available values:

widthPtAs
specifies percentage width offset between grid items(used on render step), default = 0
heightPtAs
specifies percentage height offset between grid items(used on render step), default = 0
widthPxAs
specifies px width offset between grid items(used on render step), default = 0
heightPxAs
specifies px height offset between grid items(used on render step), default = 0
repackSize
specifies items repack count on new items inserts(with enabled rsort), default = items.length
insertRange
sets max px distance from grid end/start, where next item can be inserted, default = 3000

Notice.
Per most grids 3000px is enough insertion range per Gridifier. This setting could be used with enabled sort dispersion, when small items are inserted after large count of big items.

vpResizeDelay
sets ms timeout, after which Gridifier will reposition all grid items on viewport resizes, default = null
queueSize
sets size of reposition queue, default = 12

Notice.
With this setting you can control items count in one batch, processed by reposition queue. This can be especially useful with disabled intersections, when custom aligns(center, right, bottom) are used.

Because of dynamical aligns used with NIS mode, you can encounter situation, when some items are 'jumping' on grid repositions. This happens when not biggest item is reinserted first in row/col and next row/col items are reinserted in next batch.

So, item gets to the render queue before other row/col items are reinserted in next batch. This is the moment when jump occurs. If you will see this behaviour, you can set this setting to bigger value.

queueDelay
sets ms timeout between reposition queue launches, default = 25

Api settings

sort
specifies collected DomCollection sorting, default = 'default'

var asyncGrid = new Gridifier(grid, {
    // Sort can be passed as object with function name/function pairs
    // ('default' sort(by array order) will be enabled by default)
    sort: {
        // You can set initial used function with 'selected' param
        selected: "firstSort",

        // Sort(third param) is a special object with sort helpers
        firstSort: function(first, second, sort) { /* Return sort comparator result */ },
        // ... More functions
    }
});

var asyncGrid = new Gridifier(grid, {
    // Sort also can be passed as single function
    // (Will be enabled by default and available with name "userfn")
    sort: function(first, second, sort) { /* Return sort comparator result */ }
});

var asyncGrid = new Gridifier(grid, {
    // sort param also can be used to set initial sort(string)
    sort: "sortName"
});

// Available functions in sort helper(3-rd parameter)
var sort = {
    "byOriginalPos": function(first, second) { ... },

    "byData": function(first, second, dataAttr, reverseOrder, replacers) { ... },
    "byDataInt": function(first, second, dataAttr, reverseOrder, replacers) { ... },
    "byDataFloat": function(first, second, dataAttr, reverseOrder, replacers) { ... },

    "byContent": function(first, second, reverseOrder, replacers) { ... },
    "byContentInt": function(first, second, reverseOrder, replacers) { ... },
    "byContentFloat": function(first, second, reverseOrder, replacers) { ... },

    "byQuery": function(first, second, selector, reverseOrder, replacers) { ... },
    "byQueryInt": function(first, second, selector, reverseOrder, replacers) { ... },
    "byQueryFloat": function(first, second, selector, reverseOrder, replacers) { ... }
}
        
filter
specifies collected DomCollection filtering, default = 'all'

var asyncGrid = new Gridifier(grid, {
    // Filter can be passed as object with function name/function pairs
    // ('all' filter(all items) will be enabled by default)
    filter: {
        // You can set initial used function with 'selected' param
        selected: "firstFilter", // or selected: ["filter1", "filter2"] for multiple

        firstFilter: function(item) { /* Return true(collect item) or false(don't collect item) */ },
        // ... More functions
    }
});

var asyncGrid = new Gridifier(grid, {
    // Filter also can be passed as single function
    // (Will be enabled by default and available with name "userfn")
    filter: function(item) { /* Return true(collect item) or false(don't collect item) */ }
});

var asyncGrid = new Gridifier(grid, {
    // filter param also can be used to set initial filter(string|array)
    filter: "filterName" // or filter: ["firstFilter", "secondFilter"]
});
        
drag
specifies draggable item styling function, default = 'cloneCSS'

var asyncGrid = new Gridifier(grid, {
    // Draggable item styler can be passed as object with function name/function pairs
    // ('cloneCSS' styler(clones all styles) will be enabled by default)
    drag: {
        // You can set initial used function with 'selected' param
        selected: "firstStyler",

        firstStyler: function(clone) {
            // Style clone here
            // (draggable item will be cloned and appended to document body)
        },

        // ... More functions
    }
});

var asyncGrid = new Gridifier(grid, {
    // Draggable item styler also can be passed as single function
    // (Will be enabled by default and available with name "userfn")
    drag: function(clone) {
        // Style clone here
        // (draggable item will be cloned and appended to document body)
    }
});

var asyncGrid = new Gridifier(grid, {
    // draggable item styler param also can be used to set initial styler(string)
    drag: "stylerName"
});
        
toggle
specifies items show/hide animation functions, default = "scale"

var asyncGrid = new Gridifier(grid, {
    // Toggler can be passed as object with toggle subobjects
    // ('scale' toggler will be enabled by default)
    toggle: {
        // You can set initial used toggler with 'selected' param
        selected: "customToggler",

        customToggler: {
            // We will write chapter 'how to write custom toggler' later
            show: function(item, grid, other params) { /* Show code */ },
            hide: function(item, grid, other params) { /* Hide code */ }
        },

        // ... More togglers
    }
});

var asyncGrid = new Gridifier(grid, {
    // toggle param also can be used to set initial toggler
    toggle: "togglerName"
});
        
rsort
specifies special sorting, which happens on grid repositions, default = "default"

var asyncGrid = new Gridifier(grid, {
    // Reposition sort can be passed as object with function name/function pairs
    // ('default' reposition sort(disabled) will be enabled by default)
    rsort: {
        // You can set initial used sorter with 'selected' param
        selected: "firstRsort",

        firstRsort: function(connections) {
            // Sort connections array here
            // You can calculate item width and height from connection x1, x2, y1, y2 values
            return connections;
        },

        // ... More functions
    }
});

var asyncGrid = new Gridifier(grid, {
    // Reposition sort also can be passed as single function
    // (Will be enabled by default and available with name "userfn")
    rsort: function(connections) {
        // Sort connections array here
        return connections;
    }
});

var asyncGrid = new Gridifier(grid, {
    // reposition sort param also can be used to set initial sort(string)
    rsort: "rsortName"
});
        

How to change settings?

set()
set = function(name, val)
get()
get = function(name)
setApi()
setApi = function(name, val)
addApi()
addApi = function(name, settingName, fn)

var grid = new Gridifier(...);
grid.get("toggleTime"); // Returns current toggleTime - by def 500
grid.set("toggleTime", 1000); // Updates core setting with new val
grid.set([["toggleTime", 1000], ["toggleTiming", "ease"]]); // Set fn can accept array of settings
grid.set("toggleTime", 1000).set("toggleTiming", "ease"); // You can also use chaining to change multiple params

grid.addApi("sort", "newSort", function() { /* Sort here */ });
grid.setApi("sort", "newSort"); // Selects api fn
         
next: Grid types prev: Usage
Ξ
GRIDIFIER.IO
x