Skip to content

Instantly share code, notes, and snippets.

@Mons1eurEnzo
Last active June 5, 2021 20:06
Show Gist options
  • Save Mons1eurEnzo/af51d2663cbec5ea9143451725f24552 to your computer and use it in GitHub Desktop.
Save Mons1eurEnzo/af51d2663cbec5ea9143451725f24552 to your computer and use it in GitHub Desktop.
Bitrix Panel fixed (Фиксим плавающую панель сайта и панель админки Битрикса)
BX.ready(function () {
var MyPanel = BX("navmenu"), // ID ShowPanel Bitrix
BxPanel = BX.admin.panel,
FxPanel = function () {
if (window.pageYOffset >= BxPanel.DIV.clientHeight && BxPanel.isFixed() === false) {
MyPanel.style.top = 0;
} else if (BxPanel.isFixed() === true) {
MyPanel.style.top = BxPanel.DIV.clientHeight + "px";
} else {
MyPanel.style.top = BxPanel.DIV.clientHeight - window.pageYOffset + "px";
}
};
if (!!MyPanel) {
FxPanel();
window.onscroll = FxPanel;
BX.addCustomEvent('onTopPanelCollapse', BX.delegate(FxPanel, this));
BX.addCustomEvent('onTopPanelFix', BX.delegate(FxPanel, this));
}
});
<?if($GLOBALS["USER"]->IsAuthorized()):?>
<?$APPLICATION->ShowPanel();?>
<script>/*/ --- сюда вставляем JS код --- //*/</script>
<?endif;?>
@mtvphnx
Copy link

mtvphnx commented May 7, 2020

Возможно будет полезно тем, кто как и я нашел этот фикс)
После строки 15 добавьте еще один обработчик:

window.onload = FxPanel;

@samikhailov
Copy link

Спасибо, очень полезно. А есть способ прилеппить меню? Сейчас меню ездит плавно и отвлекает на себя внимание.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment