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

Fix product media slider peek #1696

Merged
merged 2 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/section-main-product.css
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ a.product__text {
}

.product__media-list .product__media-item {
width: calc(100% - 3rem);
width: calc(100% - 3rem - var(--grid-mobile-horizontal-spacing));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an additional change we can add. On a single media product, we get the controls that show up even though there is only 1 image.

It happens because of the way we set the media_count value:

assign media_count = product.media.size
if section.settings.hide_variants
  assign media_count = media_count | minus: variant_images.size | plus: 1
endif

Which seem wrong. As it means that in our single image product case, we're doing: 1 - 0 + 1 = 2 when it should just be one.
The other situation could be that we have a product with a single variant and the media is attached to it. Then it's fine cause it ends up being 1 - 1 + 1.

So I think we could add this to the if statement: if section.settings.hide_variants and product.media.size > 1

here is a video of this ^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yes, the padding issue with the first variant is still an issue here. I added a note in the PR for reference.


Expand Down
2 changes: 1 addition & 1 deletion sections/main-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{%- liquid
assign variant_images = product.images | where: 'attached_to_variant?', true | map: 'src'
assign media_count = product.media.size
if section.settings.hide_variants
if section.settings.hide_variants and media_count > 1
assign media_count = media_count | minus: variant_images.size | plus: 1
endif

Expand Down