Sizes transforms

Responsive transforms

You can dynamically transform grid item sizes with Gridifier. If you are using media-queries per grid items(and in most cases you are), you should create separate class per each sizes transform, and use them with one of responsive sizes change functions:

toggleCss()
toggleCss = function(DomCollection, classNames)
addCss()
addCss = function(DomCollection, classNames)
rmCss()
rmCss = function(DomCollection, classNames)

Parameters:



Notices:


What about width & height transitions?


Demo grid:

Transforming using toggleCss function:

var demoGrid = document.getElementById("#demo-grid");
var grid = new Gridifier(demoGrid);

TouchClickEvent.listen(demoGrid, ".grid-item", function(event) {
    grid.toggleCss(event.target, "big-grid-item");

    // In some cases toggled state can depend on many classes:
    // grid.toggleCss(event.target, ["big-grid-item1", "big-grid-item2"]);
});
        
Css

.grid-item {
    /* ... Other styles */
    width: 90px;
    height: 90px;
    margin: 10px;
    /* Of course you can use percentage sizes instead.
       For example in demo on Gridifier homepage we are using:
       width: 20%;
       height: 0;
       padding-bottom: 20%;
       margin: 0rem; */
}

.big-grid-item {
    /* ... Other styles */
    width: 200px;
    height: 200px;
}
        
Media queries

@media(max-width: 979px) {
    .grid-item {
        /* ... Other styles */
        width: 50px;
        height: 50px;
        margin: 5px;
    }

    .big-grid-item {
        /* ... Other styles */
        width: 110px;
        height: 110px;
    }
}

/* ... Other media-queries */
        

Alternatively, if you are required to change between more than 2 sizes, you can use addCss / rmCss functions: (Css is similar to upper example, except that there are 3 classes instead of 2)

Transforming using add/rmCss functions:

var demoGrid = document.getElementById("#demo-grid");
var grid = new Gridifier(demoGrid);

TouchClickEvent.listen(demoGrid, ".grid-item > .shrink-to-def", function(event) {
    grid.rmCss(event.target, ["big-grid-item", "extra-big-grid-item"]);
});

TouchClickEvent.listen(demoGrid, ".grid-item > .grow-to-big", function(event) {
    grid.rmCss(event.target, "extra-big-grid-item");
    grid.addCss(event.target, "big-grid-item");
});

TouchClickEvent.listen(demoGrid, ".grid-item > .grow-to-extra-big", function(event) {
    grid.rmCss(event.target, "big-grid-item");
    grid.addCss(event.target, "extra-big-grid-item");
});
        

Events

What events are emitted during sizes transform operations?

onCssChange event
event, which is emitted after item reposition animation finish on responsive transform function calls
next: Api functions prev: Intersections
Ξ
GRIDIFIER.IO
x