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

Is it responsive? #15

Closed
wearede opened this issue Mar 27, 2014 · 8 comments
Closed

Is it responsive? #15

wearede opened this issue Mar 27, 2014 · 8 comments

Comments

@wearede
Copy link

wearede commented Mar 27, 2014

Hi,

Great work on the plugin.

I re-read your description few times, and it looks like this implementation should be responsive. But this is not the case?

In my scenario, I used width 100% on wrapper, but image never gets enlarged or resized down. I see in css height is fixed.

What would you suggest to do in this situation?

@CRTX
Copy link

CRTX commented Mar 28, 2014

I just went through this same situation.

You can use jQuery's $(window).resize() callback to detect if the browser has been resized.

In the callback you can resize the container along with the images used and then call
$(your_image_container).twentytwenty(); at the end of the callback again to detect the new width of your images. This worked for me.

@wearede
Copy link
Author

wearede commented Mar 28, 2014

That's a hacky way though :) I wonder if plugin core could be modified to use percentages instead of fixed width. Purely css based hack I mean. Thanks for the suggestion, I will probably go that way.

@CRTX
Copy link

CRTX commented Mar 30, 2014

It's the only way to do it because the images also have to be resized along with the content box. Unless you have time to tweak all the custom CSS from the plugin that solution is "good enough" since you're using jQuery for the plugin anyway.

@wearede
Copy link
Author

wearede commented Mar 30, 2014

Yes you are absolutely right. I went jquery way 👍

@wearede
Copy link
Author

wearede commented Mar 30, 2014

hm, running this: $(your_image_container).twentytwenty(); on the element which had previously twentytwenty active adds unnesseary containers. Basically on each run it recreates divs needed for the plugin, creating a big mess of nested containers. Did yo notice this?

We need a way to destruct plugin and relaunch it.

@CRTX
Copy link

CRTX commented Mar 31, 2014

Should probably make another thread about that :)

@mhayes mhayes closed this as completed in 28e8773 May 20, 2014
@mhayes
Copy link
Contributor

mhayes commented May 20, 2014

tl;dr - This is responsive, but it depends on img tags having a max-width set to 100%.

When using this plugin with Foundation this has already been set. The commit above adds this max-width property to all twentytwenty-container instances so it should work without Foundation.

There is a window resize event already in place that adjusts the container height (letting css control the image width):

https://github.com/zurb/twentytwenty/blob/master/js/jquery.twentytwenty.js#L57

Thanks for pointing this out, cheers!

@rflx
Copy link

rflx commented Aug 12, 2015

Hi mhayes – nice plugin, thank you for this one!
Just came across with this responsive issue. If I use the plugin out of the box, the image will scale when i'm resizing the browser window but it will be stretched due of a fixed height value in the twentytwenty-container element.

I don't know, but should there be used height: auto; to scale the img height according to the width?

Cheers

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

No branches or pull requests

3 participants