metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.53k stars 602 forks source link

Add attribute to specify larger image version for fullscreen view #876

Closed wc-matteo closed 5 years ago

wc-matteo commented 5 years ago

And the image switch happening when entering/exiting fullscreen

desandro commented 5 years ago

To be clear, do you want to show a different image when fullscreen?

wc-matteo commented 5 years ago

Yes

desandro commented 5 years ago

Here are two ways:

Display different <img> with .is-fullscreen CSS.

<div class="carousel-cell">
  <img class="image-preview" src="preview.jpg" />
  <img class="image-fullscreen" src="fullscreen.jpg" />
</div>
/* hide by default */
.image-fullscreen { display: none; }

/* show fullscreen image when fullscreen */
.carousel.is-fullscreen .image-preview { display: none; }
.carousel.is-fullscreen .image-fullscreen { display: block; }

Or you can dynamically change the image src attribute on fullscreenChange event

wc-matteo commented 5 years ago

Thank you.

Yes, I had changed the src using the fullscreenChange event. I was wondering if this could be something offered out of the box.

desandro commented 5 years ago

I am considering a separate library that focuses just on photo carousels. But, for Flickity specifically, I think this behavior is better address in your code, to allow the most flexibility.