Поддержка одиночного элемента
This commit is contained in:
parent
027de13831
commit
6eba60b7cb
8
index.js
8
index.js
|
@ -310,6 +310,13 @@ const init = async (items = [], options = {}, index = 0) => {
|
|||
|
||||
export default (container, options) => {
|
||||
const items = [];
|
||||
if (options.single) {
|
||||
items.push(container.href);
|
||||
container.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
init(items, options);
|
||||
});
|
||||
} else {
|
||||
for (const [index, element] of [...container.children].entries()) {
|
||||
items.push(element.href);
|
||||
element.addEventListener('click', (event) => {
|
||||
|
@ -317,4 +324,5 @@ export default (container, options) => {
|
|||
init(items, options, index);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue