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

Bugfix maxHeight after $.colorbox.resize() #635

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

lufton
Copy link

@lufton lufton commented Aug 13, 2014

Earlier, if I set .colorbox{maxHeight:'95%'...} then colorbox frame gets vertical scrollbar (if content is heighter than frame) but if then I do $.colorbox.resize() my colorbox frame becomes heighter than wrapper page and my maxHeight option is ignored, so this is bugfix for it.

Earlier, if I set .colorbox{maxHeight:'95%'...} then colorbox frame gets vertical scrollbar (if content is heighter than frame) but if then I do $.colorbox.resize() my colorbox frame becomes heighter than wrapper page and my maxHeight option is ignored, so this is bugfix for it.
@lufton lufton mentioned this pull request Aug 13, 2014
@@ -733,6 +733,7 @@
scrolltop = $loaded.scrollTop();
$loaded.css({height: "auto"});
settings.h = $loaded.height();
if (settings.h > settings.mh) settings.h=settings.mh;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't following code be more explicit:

settings.h = Math.min(settings.h, settings.mh);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! That would be perfect!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, please make necessary adjustments to your PR code then. Also don't forget to squash the commits.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe then settings.h = Math.min($loaded.height(), settings.mh); ?

2014-08-13 11:55 GMT+03:00 Alexander Obuhovich notifications@github.com:

In jquery.colorbox.js:

@@ -733,6 +733,7 @@
scrolltop = $loaded.scrollTop();
$loaded.css({height: "auto"});
settings.h = $loaded.height();

  •           if (settings.h > settings.mh) settings.h=settings.mh;
    

Great, please make necessary adjustments to your PR code then. Also don't
forget to squash the commits.


Reply to this email directly or view it on GitHub
https://github.com/jackmoore/colorbox/pull/635/files#r16164162.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's your PR. I've just modified your code to make it easier to read. Honestly I don't even understand what you've changed in code and how exactly it helps in solving the problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is few jsfiddles:

  1. With original script: http://jsfiddle.net/srhn524o/
  2. With fixed script: http://jsfiddle.net/1gdgh4kj/
    Press Open and the Resize button

2014-08-13 12:00 GMT+03:00 Alexander Obuhovich notifications@github.com:

In jquery.colorbox.js:

@@ -733,6 +733,7 @@
scrolltop = $loaded.scrollTop();
$loaded.css({height: "auto"});
settings.h = $loaded.height();

  •           if (settings.h > settings.mh) settings.h=settings.mh;
    

It's your PR. I've just modified your code to make it easier to read.
Honestly I don't even understand what you've changed in code and how
exactly it helps in solving the problem.


Reply to this email directly or view it on GitHub
https://github.com/jackmoore/colorbox/pull/635/files#r16164305.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One, that you indicated as fixed do nothing. I click resize and nothing happens. The original script resized colorbox beyond possible screen space.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It resizes it to overflow page if contents is too large even if I set
maxHeight: 95%.
13.08.2014 12:35 пользователь "Alexander Obuhovich" <
notifications@github.com> написал:

In jquery.colorbox.js:

@@ -733,6 +733,7 @@
scrolltop = $loaded.scrollTop();
$loaded.css({height: "auto"});
settings.h = $loaded.height();

  •           if (settings.h > settings.mh) settings.h=settings.mh;
    

One, that you indicated as fixed do nothing. I click resize and nothing
happens. The original script resized colorbox beyond possible screen space.


Reply to this email directly or view it on GitHub
https://github.com/jackmoore/colorbox/pull/635/files#r16165855.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, now I get it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you merge this? How to implement correct resize after window resize in
case of maxHeight is configured?

2014-08-13 12:46 GMT+03:00 Alexander Obuhovich notifications@github.com:

In jquery.colorbox.js:

@@ -733,6 +733,7 @@
scrolltop = $loaded.scrollTop();
$loaded.css({height: "auto"});
settings.h = $loaded.height();

  •           if (settings.h > settings.mh) settings.h=settings.mh;
    

OK, now I get it.


Reply to this email directly or view it on GitHub
https://github.com/jackmoore/colorbox/pull/635/files#r16166268.

@aik099
Copy link

aik099 commented Aug 13, 2014

Will you merge this?

I don't have merge rights on this repo.

How to implement correct resize after window resize in case of maxHeight is configured?

No idea.

@albell
Copy link

albell commented Oct 29, 2014

+1 I've encountered this problem before. Thanks @lufton.

@websiteduck
Copy link

+1 This fix worked for me, thank you.

@gonssal
Copy link

gonssal commented Mar 30, 2016

Just tested this, works fine. Thanks @lufton.

Needs merging, current code ignores maxHeight when resizing.

Tested in a site that makes heavy use of colorbox (multiple "nested" colorboxes by changing its content, image galleries, product quick views, etc...)

I'm not sure it should default to 100% max height though, because it could possibly affect current implementations. In my opinion it should maintain current behaviour when no maxHeight is set.

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

Successfully merging this pull request may close these issues.

5 participants