MurhafSousli / ngx-gallery

Angular Gallery, Carousel and Lightbox
https://ngx-gallery.netlify.app/
MIT License
602 stars 128 forks source link

imageSize = cover working as though imageSize = contain selected #610

Closed nbarrett closed 3 months ago

nbarrett commented 3 months ago

What is the expected behavior?

What is the current behavior?

On my production site for example here I've hardcoded imageSize = cover on the gallery component. You can visit that page, and go into the inspector and see the attribute on the gallery correctly set.

What are the steps to reproduce?

I then attempted to create a stackblitz project which I then did using exactly the same images as the above example which is here but annoyingly that example works exactly correctly! Do you have any idea why the behaviour is different between the stackbitz project and my prod site please as I've been scratching my head for the last few days to no avail.

What is the use-case or motivation for changing an existing behavior?

Gallery doesn't look quite as good when there are black borders, and like the author of ngx-gallery, I'm want perfection!

Which versions are you using for the following packages?

Angular: 16.2.9 Angular CDK: 16.2.9 Angular CLI:16.2.9 Typescript: 4.9.5 Gallery: 11.0.0

Is there anything else we should know?

MurhafSousli commented 3 months ago

Maybe you are calling a function that sets the config from the service or component ref, I suggest you try to set the gallery items using the items input of the gallery then see if cover is applied

nbarrett commented 3 months ago

On my production site, I have tried initialising the gallery both with Template Binding (as per stackblitz) and via Gallery Service and it still behaves the same. I also tried initialising the stackblitz project via a Gallery Service and this consistently works so there's something about my project that's making it not work. Can you suggest by looking at the inspector on my project what might be wrong?

MurhafSousli commented 3 months ago

The production site doesn't help, if you share a link to the repo maybe I can check your code.

nbarrett commented 3 months ago

Thanks for your offer to look at the repo - this is the area of code where the gallery component is located: https://github.com/nbarrett/ngx-ramblers/blob/main/projects/ngx-ramblers/src/app/album/view/album-gallery.ts

MurhafSousli commented 3 months ago

https://github.com/nbarrett/ngx-ramblers/blob/167c7aaa2e26d89ea384946da08798da5995ebb5/projects/ngx-ramblers/src/app/album/view/album-gallery.ts#L88

Try this

 this.galleryRef = this.gallery.ref(this.galleryId, {
   imageSize: 'cover'
 });
nbarrett commented 3 months ago

thanks for suggestion - sadly that didn't make any difference 😞 - can you think of anything else I can do to diagnose this problem please?

MurhafSousli commented 3 months ago

You can try setting imageSize in the global config

nbarrett commented 3 months ago

Thanks for pointer @MurhafSousli! I never thought to look at my global config which I must have copied from somewhere but it had both:

autoHeight: true,
imageSize: "cover"