Skip to content

Commit 2864cfd

Browse files
author
mreishman
committed
bugfix for scroll dropdown menu
1 parent 9a66b4b commit 2864cfd

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

core/html/changelog.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<li>
2020
Expand menu dropdown near bottom of screen now changes directions on first click
2121
</li>
22+
<li>
23+
Expand menu dropdown follows scroll of window
24+
</li>
2225
</ul>
2326
</li>
2427
</ul>

core/js/main.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var updating = false;
33
var pollTimer = null;
44
var blocekdInnerObj = {};
55
var currentIdOfMainSidebar = "";
6+
var currentOpenMenu = "";
67

78
function escapeHTML(unsafeStr)
89
{
@@ -1642,6 +1643,7 @@ function dropdownShow(nameOfElem)
16421643
{
16431644
$('.dropdown-content').hide();
16441645
$('.dropdown-content').css('margin-top',"0px");
1646+
currentOpenMenu = "";
16451647
}
16461648
else
16471649
{
@@ -1657,17 +1659,51 @@ function dropdownShow(nameOfElem)
16571659
{
16581660
currentElement.style.marginTop = "-"+(currentElement.offsetHeight+25)+"px";
16591661
}
1662+
currentOpenMenu = nameOfElem;
16601663
}
16611664
}
16621665

1666+
$( "#windows" ).scroll(function() {
1667+
let nameOfElem = currentOpenMenu;
1668+
if(nameOfElem === "")
1669+
{
1670+
return;
1671+
}
1672+
if(document.getElementById("dropdown-"+nameOfElem).style.display === 'block')
1673+
{
1674+
let heightWindow = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
1675+
if($("#innerFirstDevBox"+nameOfElem+" .expandMenu").position().top < 0 || ($("#innerFirstDevBox"+nameOfElem+" .expandMenu").position().top) > heightWindow)
1676+
{
1677+
forceCloseDropdownMenu();
1678+
}
1679+
else
1680+
{
1681+
let currentElement = document.getElementById("dropdown-"+nameOfElem);
1682+
$("#dropdown-"+nameOfElem).css("top" , "" + ($("#innerFirstDevBox"+nameOfElem+" .expandMenu").position().top + $("#innerFirstDevBox"+nameOfElem+" .expandMenu").height()) + "px")
1683+
let elementLowestPosition = (currentElement.getBoundingClientRect().top+currentElement.offsetHeight);
1684+
let heightWindow = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
1685+
if(elementLowestPosition > heightWindow)
1686+
{
1687+
currentElement.style.marginTop = "-"+(currentElement.offsetHeight+25)+"px";
1688+
}
1689+
}
1690+
}
1691+
});
1692+
16631693
window.onclick = function(event) {
16641694
if (!event.target.matches('.expandMenu'))
16651695
{
1666-
$('.dropdown-content').hide();
1667-
$('.dropdown-content').css('margin-top',"0px");
1696+
forceCloseDropdownMenu();
16681697
}
16691698
}
16701699

1700+
function forceCloseDropdownMenu()
1701+
{
1702+
$('.dropdown-content').hide();
1703+
$('.dropdown-content').css('margin-top',"0px");
1704+
currentOpenMenu = "";
1705+
}
1706+
16711707
function showUpdateCheckPopup(data)
16721708
{
16731709
showPopup();

0 commit comments

Comments
 (0)