kombai / freewall

Freewall is a cross-browser and responsive jQuery plugin to help you create grid, image and masonry layouts for desktop, mobile, and tablet...
MIT License
1.85k stars 375 forks source link

onResize, setbricks to all be the same size when window width is narrow #185

Closed alexelash closed 9 years ago

alexelash commented 9 years ago

Hi,

Wondering if this is possible. I have bricks of all different proportions and sizes. On a mobile screen, however, I want these bricks to all stack as perfect squares. Is it possible to force the bricks to take on a square format with Freewall?

Code:

        wall.reset({
            selector: '.grid-item',
            animate: true,
            cellW: 0.25,
            cellH: 0.25,
            gutterX: 1,
            gutterY: 1,
            onResize: function() {
                wall.fitWidth();
            },
        });

Desktop: screen shot 2015-08-27 at 10 29 19 am

Mobile screen shot 2015-08-27 at 10 29 29 am

kombai commented 9 years ago

Hi, Please try with this code:


wall.reset({
            selector: '.grid-item',
            animate: true,
            cellW: function() {
              var width =  $(window).width();
              if (width < 1000) return width;
             else return 0.25;
           },
            cellH:  function() {
              var width =  $(window).width();
              if (width < 1000) return width;
             else return 0.25;
           },
            gutterX: 1,
            gutterY: 1,
            onResize: function() {
               var width =  $(window).width();
               if (width < 1000) {
                   wall.container.find(".brick").css({
                      width: width,
                      height: width
                  })  
              }
                wall.fitWidth();
            },
        });

```js

it not exactly but you can look and modify for fit your issue. The idea is when it is mobile screen. 
You must take the screen width then set  as width and height for all item.
Best.
alexelash commented 9 years ago

Wow. Thank you so much, I wish I had thought of that! It actually is exactly what I was looking for. Really appreciate it! And thanks again for making such a great plugin!