TRI-283: add feader fixed

This commit is contained in:
2024-11-20 22:55:34 +03:00
parent 6f646264dc
commit b0db3534f2
4 changed files with 41 additions and 4 deletions

View File

@@ -240,7 +240,10 @@ b {
.header {
margin-top: 0;
position: relative;
position: fixed;
left: 0;
top: 0;
width: 100vw;
padding: 40px 5px;
}

View File

@@ -1,6 +1,9 @@
.header {
margin-top: 0;
position: relative;
position: fixed;
left: 0;
top: 0;
width: 100vw;
padding: 40px 5px;
}

View File

@@ -1,6 +1,9 @@
.header {
margin-top: 0;
position: relative;
position: fixed;
left: 0;
top: 0;
width: 100vw;
padding: 40px 5px;
@media (max-width: 1304.98px) {

View File

@@ -49,4 +49,32 @@
</div>
</div>
</div>
</header>
</header>
<script>
function initHeaderState() {
var activeClassname = 'scrolled';
var $document = $(document);
var headerTop = $('.header');
console.log('dfsdfdsfsdfsdfsdfsfsfsfsdfsdf')
var header = $('.header');
$(window).off('scroll.header').on('scroll.header', function() {
var scrollTop = $document.scrollTop();
var headerHeight = header.outerHeight();
var headerHeightTop = headerTop.outerHeight();
var top = headerHeight - headerHeightTop - 20;
if (scrollTop > headerHeight) {
console.log(scrollTop, top)
headerTop.addClass(activeClassname);
$(document.body).addClass(activeClassname);
} else {
headerTop.removeClass(activeClassname);
$(document.body).removeClass(activeClassname);
}
});
}
$(document).ready(()=>{
initHeaderState();
})
console.log($,'sdsdads')
</script>