function getNavigationTablet(navItems) {
navItems = navItems.slice(0, 4);
navItems.push(
{
id: 5,
title: 'ещё',
children: []
}
);
navItems.find(item => item.id === 5).children = navItems.slice(4, navItems.length);
return navItems
}
navItems.slice(5, navItems.length) = []
(5) [{…}, {…}, {…}, {…}, {…}]
0: {id: 1, title: "Пункт 1", children: Array(1)}
1: {id: 2, title: "Пункт 2", children: Array(1)}
2: {id: 3, title: "Пункт 3", children: Array(1)}
3: {id: 4, title: "Пункт 1", children: Array(1)}
4:
id: 5
title: "ещё"
children: []
children = navItems.find(item => item.id === 5).children;
children.splice(0, children.length, ...navItems.slice(5, navItems.length))
import { sortItemsInOrder } from '../help_functions';
export let navigationItems = sortItemsInOrder([
{
id: 3,
title: 'Пункт 3',
children: [
{
id: 3.1,
title: 'Пункт 1'
}
]
},
{
id: 2,
title: 'Пункт 2',
children: [
{
id: 2.1,
title: 'Пункт 1'
}
]
},
{
id: 1,
title: 'Пункт 1',
children: [
{
id: 1.1,
title: 'Пункт 1'
}
]
},
{
id: 4,
title: 'Пункт 1',
children: [
{
id: 4.1,
title: 'Пункт 1'
}
]
},
{
id: 5,
title: 'Пункт 1',
children: [
{
id: 5.1,
title: 'Пункт 1'
}
]
},
{
id: 6,
title: 'Пункт 1',
children: [
{
id: 6.1,
title: 'Пункт 1'
}
]
},
{
id: 7,
title: 'Пункт 1',
children: [
{
id: 7.1,
title: 'Пункт 1'
}
]
},
{
id: 8,
title: 'Пункт 1',
children: [
{
id: 8.1,
title: 'Пункт 1'
}
]
},
{
id: 9,
title: 'Пункт 1',
children: [
{
id: 9.1,
title: 'Пункт 1'
}
]
}
]);