Поддержка одиночного элемента
This commit is contained in:
16
index.js
16
index.js
@@ -308,11 +308,19 @@ const init = async (items = [], options = {}, index = 0) => {
|
||||
|
||||
export default (container, options) => {
|
||||
const items = [];
|
||||
for (const [index, element] of [...container.children].entries()) {
|
||||
items.push(element.href);
|
||||
element.addEventListener('click', (event) => {
|
||||
if (options.single) {
|
||||
items.push(container.href);
|
||||
container.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
init(items, options, index);
|
||||
init(items, options);
|
||||
});
|
||||
} else {
|
||||
for (const [index, element] of [...container.children].entries()) {
|
||||
items.push(element.href);
|
||||
element.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
init(items, options, index);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user