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

Images not taking full width, overlapping #2131

Open
murolem opened this issue Nov 12, 2024 · 0 comments
Open

Images not taking full width, overlapping #2131

murolem opened this issue Nov 12, 2024 · 0 comments

Comments

@murolem
Copy link

murolem commented Nov 12, 2024

Here's a sample of the gallery open, from left to right side of a page. Vertical space is cut out.
image

You can see 2 images (rectangles). I want to see only one image at a time, taking the full viewport width. How to do that?

I'm getting this behavior on mobile only (including desktop devtools in mobile mode). Making the browser window on desktop narrow has no effect - each image takes full width.

Some things:

  • The currently open image is "stuck" to the left part of the page. The gap is to the right.
  • When zoomed in, the image to the right overlaps with the current image.
  • I tried setting initialZoomLevel to fit with no effect.
  • I'm setting both data-pswp-width and data-pswp-height correctly.
  • Setting padding is not an option - the gap changes between resolutions.
  • I'm using svelte-kit with dynamic imports and some format preprocessing, but disabling the latter has no effect (as shown by the code samples). The code is based on the svelte example in the docs.

Also, when inspecting an opened image, I see width and height set to width: 500px; height: 374px (I have a 2398x1795 image), even on big resolutions. Is this okay? Changing these values manually changes the image size but does not affect the position of the next image.

Here's some code samples:

  • importing images
const imageModulesPromises = imageFiles.map(
        ({ category, fullFilenameWithoutExt }) => {
            return import(
                `$catalog/${category}/${fullFilenameWithoutExt}.jpg`
            );
        }
    );
  • creating gallery
    onMount(() => {
        let lightbox = new PhotoSwipeLightbox({
            gallery: "#" + galleryID,
            children: "a",
            pswpModule: () => import("photoswipe")
        });
    });
  • svelte html
<div class="pswp-gallery" id={galleryID}>
    {#await Promise.all(imageModulesPromises) then imageModules}
        {#each imageModules as imageModule, i}
            <a
                href={imageModule.default}
                data-pswp-width={imageFiles[i].fullImageWidth}
                data-pswp-height={imageFiles[i].fullImageHeight}
                target="_blank"
                rel="noreferrer"
            ></a>
        {/each}
    {/await}
</div>
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