routes.js
export const PAGE = { pageName: `/url/example`} // для роутинга
export const apiRoute = {getElement: '/get/element/:id'} // для api запросов
import {PAGE} from 'config'
componentDidMount() {
window.addEventListener('scroll', this.handleScroll);
}
componentWillUnmount() {
window.removeEventListener('scroll', this.handleScroll);
}
handleScroll = (event) => {
let scrollTop = event.srcElement.body.scrollTop,
itemTranslate = Math.min(0, scrollTop/3 - 60);
console.log(itemTranslate);
this.setState({
transform: itemTranslate
});
}
body::-webkit-scrollbar {
width: 1em;
}
body::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
body::-webkit-scrollbar-thumb {
background-color: orange;
outline: 1px solid slategrey;
}
$(function() {
$(window).scroll(function() {
var scroll = $(window).scrollTop() + 90;
var currentArea = $("section").filter(function() {
return scroll <= $(this).offset().top + $(this).height();
});
$(".nav a").removeClass("selected");
$(".nav a[href=#" + currentArea.attr("id") + "]").addClass("selected");
if ($(window).scrollTop() > 100) {
$('nav').addClass("navScroll");
$('img.logo').addClass("logoScroll");
$('div.menu').addClass("menuScroll");
} else if ($(window).scrollTop() < 100 ) {
$('nav').removeClass("navScroll");
$('img.logo').removeClass("logoScroll");
$('div.menu').removeClass("menuScroll");
}
});
});