Better menu positioning code.

This commit is contained in:
Nicolas Stepien 2013-03-03 04:39:48 +01:00
parent 1cb7f9c6c1
commit c8e2b23faf
3 changed files with 11 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@ -734,6 +734,7 @@ a[href="javascript:;"] {
border-bottom: 0;
display: -webkit-flex;
display: flex;
margin: 2px 0;
-webkit-flex-direction: column;
flex-direction: column;
position: absolute;

View File

@ -67,19 +67,14 @@ UI = do ->
bLeft = doc.scrollLeft + d.body.scrollLeft + bRect.left
cHeight = doc.clientHeight
cWidth = doc.clientWidth
if bRect.top + bRect.height + mRect.height < cHeight
# XXX calc(100% + 2px) would have been better, but >Presto.
top = bRect.height + 2 + 'px'
bottom = 'auto'
[top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight
['100%', null]
else
top = 'auto'
bottom = bRect.height + 2 + 'px'
if bRect.left + mRect.width < cWidth
left = '0px'
right = 'auto'
[null, '100%']
[left, right] = if bRect.left + mRect.width < cWidth
['0px', null]
else
left = 'auto'
right = '0px'
[null, '0px']
{style} = menu
style.top = top
style.right = right