FitVids.js icon indicating copy to clipboard operation
FitVids.js copied to clipboard

Doesn't work with floated elements

Open randysrodeo opened this issue 10 years ago • 4 comments
trafficstars

I recently identified what I think is a weakness of the FitVids script - which I have otherwise found quite valuable, by the way. It doesn't account for floated elements when calculating the video container width, thus obscuring all or part of the floated element.

You can see it twice, first in a simple mockup with one floated div (hidden) and one video: http://www.dfps.state.tx.us/Child_Protection/About_Child_Protective_Services/transformation/video.html

And then, in a copy of a working page built on jQuery and Bootstrap: http://www.dfps.state.tx.us/Child_Protection/About_Child_Protective_Services/transformation/default-test.asp

I'm not enough of a coder to solve this. Any ideas? Essentially, I think we need to calculate width after the float is applied...

FYI, here's what it looks like after I wrapped the main video in a Bootstrap-specific element. It works, but I'd much rather it work automatically - without the extra code. http://www.dfps.state.tx.us/Child_Protection/About_Child_Protective_Services/transformation/default.asp

randysrodeo avatar May 26 '15 23:05 randysrodeo

Without adding extra markup, I don't see a particularly elegant way to make this happen. Calculating the width of (potentially interfering) floating elements seems really hard, though I wouldn't be shocked if someone proves me wrong!

For what it's worth, by adding a few styles to .fluid-width-video-wrapper, you can make it work in the scenarios you listed. See this pen for an example:

http://codepen.io/andyadams/pen/QbGRwP

I'm not sure if this would affect other places you're using fitvids, but you could change the selector to be specific to these particular pages - something like #content-text .fluid-width-video-wrapper, to limit the side effects.

andyadams avatar May 28 '15 00:05 andyadams

Interesting, and thanks. If I also use max-width:auto, it works - doesn't obscure floated element and does not interfere with the float. But, it messes up the aspect ratio of the video....

.fluid-width-video-wrapper { max-width: auto; overflow: hidden; width: auto; }

Simple example: http://www.dfps.state.tx.us/Child_Protection/About_Child_Protective_Services/transformation/video.html

Applied example: http://www.dfps.state.tx.us/Child_Protection/About_Child_Protective_Services/transformation/default-test.asp

But, if I leave the additional wrapper on, it works as before - which means we're (almost) back to where we started: http://www.dfps.state.tx.us/Child_Protection/About_Child_Protective_Services/transformation/default.asp

What I'd like to do is amend the javascript where it incorporates the float into the width calculation. I've seen this concept brought up in similar scripts but, like I said, I'm no coder....

randysrodeo avatar May 28 '15 19:05 randysrodeo

Howdy! It's been a couple years. Was a decent resolution met here? Does FitVids need to address anything here?

davatron5000 avatar Jan 27 '17 18:01 davatron5000

Floated content is hardly uncommon, so it'd sure be nice if FitVids could address it.

Here's the current link: http://www.dfps.state.tx.us/Child_Protection/Transformation/default.asp

I have temporarily "unwrapped" the video so you can see the problem. I'll leave it that way for a couple of days to give you a chance to poke around.

randyrodeo avatar Jan 27 '17 21:01 randyrodeo