Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make mobile show two columns? #212

Closed
xnog opened this issue Mar 17, 2016 · 6 comments
Closed

How can I make mobile show two columns? #212

xnog opened this issue Mar 17, 2016 · 6 comments

Comments

@xnog
Copy link

xnog commented Mar 17, 2016

Hi,

I have four columns (width: 25%) and on mobile it shows me only one column.

How can I make mobile show two columns?

var wall2 = new Freewall(".products");
wall2.reset({
selector: '.product',
animate: true,
cellW: 255,
cellH: 'auto',
onResize: function() {
wall2.fitWidth();
}
});

.product {
width: 276.5px;
}

@micahstairs
Copy link

What happens if you choose a smaller 'cellW' value?

@xnog
Copy link
Author

xnog commented Mar 18, 2016

i still get only one cell on mobile. i tried with 120

@xnog
Copy link
Author

xnog commented Mar 18, 2016

Does anyone have an example with mobile and two coluns so I can check what i am doing wrong?

@kombai
Copy link
Owner

kombai commented Mar 29, 2016

Hi,
you can using cellW as a function

cellW: function(container) {
 return container.width() / 2;
}

You can see the source code of this example:
http://vnjs.net/www/project/freewall/example/live-size.html
Best

@PhantomRay
Copy link

I didn't know cellW supports function. I give it a dynamic value according to window.innerWidth.

var width = 236;
if (window.innerWidth <= 320) {
    width = 120;
} else if (window.innerWidth <= 414) {
    width = 150;
} else if (window.innerWidth <= 667) {
    width = 200;
}

var currentWidth = window.innerWidth;
$scope.resetWall = function () {
    wall.reset({
        selector: '.card',
        animate: true,
        cellW: width,
        cellH: 'auto',
        onResize: function () {
            if (currentWidth !== window.innerWidth)
                wall.fitWidth();
        }
    });

    wall.fitWidth();

    wall.container.find('.card img').load(function () {
        wall.fitWidth();
    });
};

Working example at
https://collector.im/categories/action-figures

But I feel Kombai's solution is much better.

@kombai
Copy link
Owner

kombai commented Apr 26, 2016

@dragonfish-au that good too. Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants