Поддержка одиночного элемента
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) => {
 | 
					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);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user