Yii2 BS4 showOnUpscroll not working
cristian-dev-it opened this issue · 2 comments
Hi,
I've updated Yii2 to BS4. When I scroll down the page, correctly the navbar menu is hidden, but when I scroll top the page, the navbar menu it's not shown. It seems that the option "showOnUpscroll" is set to false, but I haven't specify it in my plugin init. The navbar menu is shown only when I scroll the page on start. I've tried also to specify "showOnUpscroll: true", but nothing changed.
Plugin init:
$('.navbar-fixed-top').autoHidingNavbar({ showOnBottom: false });
My menu:
<nav id="w0" class="navbar-inverse navbar-fixed-top navbar-expand-md navbar-dark bg-dark collapse show navbar" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggler hidden-sm-up" data-toggle="collapse" data-target="#w0-collapse"><span class="sr-only">Toggle navigation</span>
☰</button>
<a class="home-link navbar-brand" href="/DesignazioniProject/Designazioni/web/index.php?r=site%2Fhome">
<img class="logo" src="/DesignazioniProject/Designazioni/web/css/images/whistle.png" alt="">Designazioni
<div class="logo_beta">Beta</div>
<div class="welcome_message">Ciao, Cristian</div>
</a>
</div>
<div id="w0-collapse" class="collapse navbar-toggleable-xs">
<ul id="w1" class="nav">
<li class="home-link nav-item"><a class="nav-link" href="/DesignazioniProject/Designazioni/web/index.php?r=site%2Fhome"><i class="fas fa-home" style="padding-right: 10px"></i>Home</a></li>
...
...
...
</ul>
</div>
</div>
</nav>
Many thanks & best regards,
Chris.
I've upgraded the plugin to version 4.0.0 (Last Release). In my Yii2 application AppAsset I've added a link to the file js/bootstrap-autohidingnavbar/jquery.bootstrap-autohidingnavbar.min.js
.
In my js file:
$('.navbar-fixed-top').autoHidingNavbar({ showOnBottom: false, showOnUpscroll: true });
If I scroll down the menu is correctly hidden, but if I scroll to up it doesn't appear.
Could you help me please?
The issue was that bs4 is using the fixed-top
class for fixed navbars instead of the navbar-fixed-top
class in bs3.