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