Events

Kernel events

You can listen Gridifier object for various events after initialization:

Syntax: grid.onEventName(handlerFn)
add handler per 'EventName' kernel event

Notice.
You can add as many handlers as you need per each event.

Full events list

This section contains all events, that are emitted by Gridifier during it's lifecycle.

onShow()
onShow = function(item)

var grid = new Gridifier(demoGrid, settings);
grid.onShow(function(item) {
    // This event is emitted after 'show' animation end.
    // It happens after item inserts and after filter changes.
    // (If previous filtered out items are shown with current filter)
});
        
when onShow event is emitted by kernel?

// 1. Insert operations
grid.append(domCollection);
grid.prepend(domCollection);
grid.insertBefore(domCollection, beforeItem);
grid.insertAfter(domCollection, afterItem);

// 2. Filter operations
grid.filter("newFilter");
        
onHide()
onHide = function(item)

var grid = new Gridifier(demoGrid, settings);
grid.onHide(function(item) {
    // This event is emitted after 'hide' animation end.
    // It happens after item disconnects and after filter changes.
    // (If visible items are hidden with current filter)

    // If you want to delete item from DOM after hide animation end
    // and you are using filters, use onDisconnect event instead.
});
        
when onHide event is emitted by kernel?

// 1. Disconnect operations
grid.disconnect(domCollection);
grid.pop();
grid.shift();

// 2. Filter operations
grid.filter("newFilter");
        
onReposition()
onReposition = function()

var grid = new Gridifier(demoGrid, settings);
grid.onReposition(function() {
    // This event is emitted after each item reposition inside grid.
    // It should be used with silentAppend/silentRender functions to
    // render silently appended items, that are located inside viewport right after page load:
    grid.silentRender(grid.getSilent(true));
});

// Each item insert will trigger onReposition event.
grid.silentAppend(domCollection);

// notice -> don't use this event per global Gridifier functions like
// 'grid.resort()', it will create infinite loop.(use onInsert event instead)
        
when onReposition event is emitted by kernel?

// Almost in all operations(inserts, disconnects, repositions, resorts, drags...)
        
onInsert()
onInsert = function()

var grid = new Gridifier(demoGrid, settings);
grid.onInsert(function(items) {
    // This event is emitted after insert function calls.
    // Use this event if you want to resort all items after each insert.
    grid.resort();
});

grid.append(domCollection);
        
when onInsert event is emitted by kernel?

// 1. Insert operations
grid.append(domCollection);
grid.prepend(domCollection);
grid.insertBefore(domCollection, beforeItem);
grid.insertAfter(domCollection, afterItem);
grid.silentAppend(domCollection);
        
onDisconnect()
onDisconnect = function(item)

var grid = new Gridifier(demoGrid, settings);
grid.onDisconnect(function(item) {
    // This event is emitted after 'hide' animation end.
    // Opposite to 'onHide' event it is emitted only after item disconnects through
    // disconnect/pop/shift functions.

    // So, it will not be triggered on filter changes and you can use it
    // to delete item from DOM.(If it is required)
    // item.parentNode.removeChild(item);
});
        
when onDisconnect event is emitted by kernel?

// 1. Disconnect operations
grid.disconnect(domCollection);
grid.pop();
grid.shift();

// It will not be triggered on filter('fName') calls.
        
onCssChange()
onCssChange = function(item, addedClasses, removedClasses)

var grid = new Gridifier(demoGrid, settings);
grid.onCssChange(function(item, addedClasses, removedClasses) {
    // This event is emitted after item reposition animation finish.
    // (After responsive transform function calls)
    // Added and removed classes are arrays, that contains all classes,
    // which were passed to transform functions.
});
        
when onCssChange event is emitted by kernel?

// Responsive transform function calls
grid.toggleCss(item, "className");
grid.addCss(item, "className");
grid.rmCss(item, "className");
        
onRepositionEnd()
onRepositionEnd = function()

var grid = new Gridifier(demoGrid, settings);
grid.onRepositionEnd(function() {
    // This event is emitted after all grid item reposition finish.
    // It will not fire after item inserts - if you want for example reindex
    // all grid items, you should use onGridResize event.(It will fire also after item inserts)
});
        
when onRepositionEnd event is emitted by kernel?

// Almost in all operations(disconnects, retransforms, resorts, drags...) except inserts.
        
onGridResize()
onGridResize = function()

var grid = new Gridifier(demoGrid, settings);
grid.onGridResize(function() {
    // This event is emitted after almost all Gridifier operations.
    // If you want to rewrite grid item numbers, you should use this event:
    var reindexGridItems = function() {
        var items = grid.getAll();
        for(var i = 0; i < items.length; i++)
            items[i].innerHTML = i + 1;
    }

    reindexGridItems();
});

// notice -> don't use this event per global Gridifier functions like
// 'grid.resort()', it will create infinite loop.(use onInsert event instead)
        
when onGridResize event is emitted by kernel?

// Almost in all operations(disconnects, repositions, resorts, drags...) including inserts.
        
onDragEnd()
onDragEnd = function(sortedItems)

var grid = new Gridifier(demoGrid, settings);
grid.onDragEnd(function(sortedItems) {
    // This event is emitted after all grid item reposition finish when draggable item is being dragged around.
    // This event should be used to get new items order after drags.
});
        
when onDragEnd event is emitted by kernel?

// When all grid items are repositioned after draggable item movements.
         
next: Togglers prev: Functions
Ξ
GRIDIFIER.IO
x