vanilla-js-carousel icon indicating copy to clipboard operation
vanilla-js-carousel copied to clipboard

insertBefore & appendChild to keep listeners

Open rodrigonsh opened this issue 8 years ago • 1 comments

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

rodrigonsh avatar Jul 14 '17 16:07 rodrigonsh

If you want to create a pull request with the code that matters - I can review and merge it. Thanks!

zoltantothcom avatar Jul 15 '17 17:07 zoltantothcom