You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
993 B
33 lines
993 B
import $ from 'jquery';
|
|
import SmoothScroll from 'smooth-scroll/dist/js/smooth-scroll';
|
|
|
|
$(document).ready(function () {
|
|
// Добавляем заголовок X-CSRFToken для всех AJAX запросов JQuery.
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRFToken': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
|
|
// Инициируем начальное состояние шапки
|
|
updateHeader();
|
|
|
|
$(window).on('scroll', function () {
|
|
updateHeader();
|
|
});
|
|
});
|
|
|
|
function updateHeader() {
|
|
const scrollOffset = $(window).scrollTop();
|
|
const headerElement = $('header');
|
|
if (scrollOffset >= 130) {
|
|
headerElement.css('background-color', '#fff');
|
|
} else {
|
|
headerElement.css('background-color', `rgba(255, 255, 255, ${scrollOffset / 130})`);
|
|
}
|
|
if (scrollOffset >= 150) {
|
|
headerElement.addClass('header--shadow');
|
|
} else {
|
|
headerElement.removeClass('header--shadow');
|
|
}
|
|
} |