yalabot / angular-foundation

http://pineconellc.github.io/angular-foundation/
Other
1.05k stars 267 forks source link

fix(dropdownToggle): Dropdown sometimes runs off the screen #231

Closed romario333 closed 1 year ago

romario333 commented 9 years ago

dropdownToggle detects when dropdown runs off the visible viewport and inverts the dropdown direction from left to right in such case. The problem is that this detection does not work under certain circumstances as demonstrated in this codepen: http://codepen.io/romario333/pen/EjgMLM

The rersult is this (direction is not reversed and dropdown is cut off in the middle):

image

This is caused by a bug in the following code:

var left = Math.round(offset.left - parentOffset.left);
var rightThreshold = $window.innerWidth - dropdownWidth - 8;
if (left > rightThreshold) {

Note that left is relative to the closest positioned parent while rightThreshold is relative to the viewport - these are not always the same. This PR fixes this by adjusting rightThreshold to be relative to the same reference point as left. (Demo of the fix is here)

tvojtech commented 9 years ago

Guys, where is the problem merging this PR? Could you please review it and merge or comment?

danieljin commented 8 years ago

@jbrowning?