Skip to content

Drop down shift when close to the right of the screen. #180

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

Open
lishner opened this issue Jan 14, 2015 · 7 comments
Open

Drop down shift when close to the right of the screen. #180

lishner opened this issue Jan 14, 2015 · 7 comments

Comments

@lishner
Copy link

lishner commented Jan 14, 2015

There is a problem with dropdown that is too close to the right of the screen.
the fix is to reduce dropdownWidth/2 from the left size (line #462 on v0.51):
==> left = rightThreshold - dropdownWidth/2;

The all part:
var left = Math.round(offset.left - parentOffset.left);
var rightThreshold = $window.innerWidth - dropdownWidth - 8;
if (left > rightThreshold) {
left = rightThreshold - dropdownWidth/2;
dropdown.removeClass('left').addClass('right');
}

@circlingthesun
Copy link
Contributor

I'm not sure what problem you are referring to. I have noticed some nub positioning weirdness. Repositioning the drop down like this does not solve it though.

@lishner
Copy link
Author

lishner commented Jan 15, 2015

I mixed up things. Please ignore my first explanation and I will try again.

When the dropdown is too close to the right side of the window, there is a threshold (rightThreshold) that its job is to re-position the dropdown from the right side (it moves also the arrow to the right).

The problem is that the way it calc the "left" variable in this situation (I think) is wrong.
It takes this as the "left" => var rightThreshold = $window.innerWidth - dropdownWidth - 8;
left = rightThreshold;

The problem is that it's actually should take the original "left" and reduce the width of the dropdown plus 2 times the arrow shift (2 * 8px).

So I think the right fix will be:
Instead of : left = rightThreshold; (line #462)
It should be : left = left - dropdownWidth + 16;

@circlingthesun
Copy link
Contributor

This is what happens when you do that:
nub
Have a look at #177

@lishner
Copy link
Author

lishner commented Jan 15, 2015

Without the change the dropdown will just be on the right of the screen.
To see the problem try to attach your dropdown to the "bell" icon and not the man. You will see that before the fix it will be way off.

@circlingthesun
Copy link
Contributor

It looks like a better solution might be:
left = left - dropdownWidth + $position.position(element).width;
However, I have not tested this properly.

@lishner
Copy link
Author

lishner commented Jan 15, 2015

You are right.
I've tested it and it works.

On Thu, Jan 15, 2015 at 12:54 PM, Rickert Mulder [email protected]
wrote:

It looks like a better solution might be:
left = left - dropdownWidth + $position.position(element).width;
However, I have not tested this properly.


Reply to this email directly or view it on GitHub
#180 (comment)
.

@lerio
Copy link

lerio commented Sep 9, 2015

Thanks for the workaround. Is there a PR for this?

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

No branches or pull requests

3 participants