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

Portrait videos overlapping #1179

Open
g-rom87 opened this issue Dec 29, 2022 · 0 comments
Open

Portrait videos overlapping #1179

g-rom87 opened this issue Dec 29, 2022 · 0 comments

Comments

@g-rom87
Copy link

g-rom87 commented Dec 29, 2022

Hello,

I'm using this great tool for a few years now but there's still one issue bothering me. I am mixing photos with sometimes mp4 movies, which I display as html5. At the end of the code, when all images are loaded, I run the masonry script, to avoid overlapping images.

$(document).ready(function () {
  var imagesLoaded = 0
  var totalImages = $("img").length
  $("img").each(function (idx, img) {
    $("<img>").on("load", imageLoaded).attr("src", $(img).attr("src"))
  })
  function imageLoaded() {
    imagesLoaded++
	$('.grid').masonry({
	  itemSelector: '.grid-item',
	  //columnWidth: '.grid-item',
	  percentPosition: true
	});
  }
})

This works great but not for movies... It gets really bad, when movies are in portrait mode because by default, it assumes a 16:9 format. You then have 2/3 of the movie hidden behind other items. To fix this, you have to rotate the phone or change the browser zoom level on desktop because masonry then knows the size of the movie and changes the layout.

Is there a way to avoid this already on load, maybe by doing something similar like I do with the document ready for photos?

Thank you :-)

PS: I can post a live link if needed but it's hosted on a NAS at home which is not powered on all the time and the firewall only allows certain countries (can change that if needed).

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

1 participant