vanilla-js-carousel
vanilla-js-carousel copied to clipboard
insertBefore & appendChild to keep listeners
Hi
Nice code
I've made some changes in my local copy
The first is merely cosmetic
The second allows you to add event listeners to the slider's contents
[...]
selectAllSlides = '.items section'
selectContainer = '.items'
[...]
function moveItem(
[...]
if ( position == 'afterBegin' )
{
var refnode = element.querySelectorAll( selectAllSlides )[0]
element.querySelector(selectContainer)
.insertBefore(itemToMove, refnode);
}
else
{
element.querySelector('.items')
.appendChild( itemToMove )
}
In order to use the carousel in my project, I've changed the markup from (ul li) to (.items section) & did the final adjustments in the carousel CSS
If you want to create a pull request with the code that matters - I can review and merge it. Thanks!