let data = [];
let currentRow = 0;
function getPositions(){
document.querySelectorAll('.row').forEach(row => {
let box = row.getBoundingClientRect();
data.push(box.top + pageYOffset);
});
}
getPositions();
document.addEventListener('wheel', event => {
event.preventDefault();
currentRow += event.deltaY > 0 ? 1 : -1;
if (currentRow<0) currentRow = 0;
if (currentRow>data.length-1) currentRow = data.length-1;
window.scrollTo({
top: data[currentRow],
behavior: 'smooth'
});
});
window.addEventListener('resize', () => {
getPositions();
});
Ставил overflow-x на хедер, но тогда меню обрезается вообще полностью по все осям и Х, и Y, что за бред? почему по Y вы высоту меню обрезается-то??
$form.on( 'submit', function(e) {
e.preventDefault();
location.href = 'http://yandex.ru';
let s = document.querySelector('.tra-la-la').innerHTML;
s = s.replace(/^<a[^>]*>/, '').replace(/<\/a>$/, '');
document.querySelector('.tra-la-la').innerHTML = s;
let s = document.querySelector('.tra-la-la > a').innerHTML;
document.querySelector('.tra-la-la').innerHTML = s;
$('.tra-la-la').html($('.tra-la-la > a').html());
function getItem($arr, $id, $result = null)
{
foreach($arr as $key => $item) {
if ($item->rel == $id) {
return $result ?: $item;
}
}
if ($item->children) {
return getItem($item->children, $id, $result ?: $item);
}
return null;
}
// use:
$foundItem = getItem($decode, 12);
function getItem($arr, $id, $result = null)
{
foreach($arr as $key => $item) {
if ($item->rel == $id) {
return $result ?: $item;
} else {
if (is_array($item->children)) {
$res = getItem($item->children, $id, $result ?: $item);
if ($res !== null) {
return $res;
}
}
}
}
return null;
}
// use:
$foundItem = getItem($data, 8);