function formatNumber(number) {
if (number <= 1e4) return number.toString();
const rest = (number / 1e3) % 1;
const thousands = Math.floor(number / 1e3) + " т";
if (rest === 0) {
return thousands;
}
if (rest < 0.5) {
return ">" + thousands;
}
if (rest === 0.5) {
return ">" + thousands;
}
if (rest > 0.5) {
return "≈" + thousands;
}
}
const sections = [
{
section: sectionOne,
button: sectionOneButton
},
{
section: sectionTwo,
button: sectionTwoButton
},
// остальные секции
];
window.addEventListener('scroll', () => {
const offsets = sections.map(section => {
const rect = section.section.getBoundingClientRect();
return {
top: rect.top - menuFixedHeight,
bottom: rect.bottom - menuFixedHeight,
};
})
offsets.forEach((offset, key) => {
if (offset.top <= 0 && (key === 0 || offsets[key - 1].bottom <= 0)) {
sections[key].button.classList.add('active');
if (key !== 0) {
sections[key - 1].button.classList.remove('active');
}
}
})
}
let oldX, oldY;
document.onmousemove = function f32() {
let x = event.clientX/192.0*3,
y = event.clientY/950*6;
if (oldX !== x) {
// Изменился x
...
} elseif (oldY !== y) {
// Изменился y
...
}
oldX = x;
oldY = y;
...
const X_MAX_DIFF = ...;
const Y_MAX_DIFF = ...;
let oldX, oldY;
document.onmousemove = function f32() {
let x = event.clientX/192.0*3,
y = event.clientY/950*6;
if (Math.abs(oldX - x) < X_MAX_DIFF) {
// Изменился x
...
} elseif (Math.abs(oldY - y) < Y_MAX_DIFF) {
// Изменился y
...
}
oldX = x;
oldY = y;
...
buttons.map((item) => {
let one = item.one;
let two = item.two;
return (`${one} ${two}`)
})