jackmoore / colorbox

A light-weight, customizable lightbox plugin for jQuery
http://www.jacklmoore.com/colorbox/
MIT License
4.75k stars 1.14k forks source link

Add redraw() public method. #886

Open markus-drupal opened 4 years ago

markus-drupal commented 4 years ago

This is necesssary to be able to redraw the colorbox on the current slide to force re-position or resize based on events that are not controlled by dom events. It is not possible to implement such a method from outside the colorbox plugin because it uses internal variables that cannot be accessed from the outter space...

jackmoore commented 4 years ago

Sorry, it's been a long time since I looked at this code. Did you try calling $.colorbox.resize()? It was intended to address the situation I think you are describing, but maybe I'm missing something.

markus-drupal commented 4 years ago

Hi Jack, thanks for checking this as fast!

I tried resize first, but it does not compute well the new size of the modal. When using the next/prev methods did it well, so I implemented this redraw() idea, which is just like next/prev on the current slide. The magic that works well to compute the new dimensions and position of the model happens in launch().

Oh and I just added a new commit to ensure the modal is not re-opened if it was closed.

Regards! Marc