simplelightbox icon indicating copy to clipboard operation
simplelightbox copied to clipboard

Feature: consider caption outside when calculating the value "top"

Open nom10s opened this issue 7 years ago • 4 comments

Thank you very much for the great work!

I have a suggestion: Please consider the value "outside" for the property "options.captionPosition" when calculating the value "top". Since at the time of calculation it will be unknown how high the "sl-caption.pos-outside" will be, an option would be desirable to adjust the distance of the image to the upper edge ("top").

In simple-lightbox.js (v 1.13.0), line 234, this does the job for me top': ( $( window ).height() - imageHeight ) / 2 + 70 + 'px', where 70 is half the height of "sl-caption.pos-outside". Maybe you have a better idea to solve the problem.

Have a nice day. Stefan

nom10s avatar Aug 31 '18 11:08 nom10s

Dear Andre,

I enjoy your great work as well and would like to support this request. Sometimes I add short description to images and most of the text is cut off in landscape format. I'm not good at programming and can't modify the code to achieve that.

Thank you very much.

NjamNjamNjam avatar May 21 '21 09:05 NjamNjamNjam

It is a little bit tricky to do this. I will take a look.

andreknieriem avatar Jun 09 '21 11:06 andreknieriem

I was just about to open a new issue, & found this related.

I'm having trouble when large images (already constrained to heightRatio: .85) don't leave enough space at the bottom of the screen for long captions to fit on the page.

I know that a challenge here is that the size of the caption element would need to be rendered to be measured. But it also looks like the image position is calculated (here) before the caption is built.

A simple resolution might be a setting that allows the top edge of the image to be positioned at the top of the page, instead of calculated to appear centered vertically. But that still wouldn't help for excessively long captions.

Any thoughts on approaches for resolving this?

g000m avatar Feb 06 '24 21:02 g000m

I "solved" the problem by reducing the image height by the height of the caption. This looks a bit ugly (the width of the caption still corresponds to the width of the original image), but it works.

simpleLightBoxOutsideCaption

janisdd avatar Feb 13 '24 19:02 janisdd