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; border-bottom: 0;
display: -webkit-flex; display: -webkit-flex;
display: flex; display: flex;
margin: 2px 0;
-webkit-flex-direction: column; -webkit-flex-direction: column;
flex-direction: column; flex-direction: column;
position: absolute; position: absolute;

View File

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