kornelski / slip

Slip.js — UI library for manipulating lists via swipe and drag gestures
BSD 2-Clause "Simplified" License
2.44k stars 213 forks source link

Suggestion: ignore elements #101

Closed myfrom closed 6 years ago

myfrom commented 6 years ago

Hello! I'm developing an app with Polymer and I came across a situation in which I have a list of items rendered by a dom-repeat element. This element has display: none but is a sibling to rendered items. It looks somewhat like this:

<div id="slip-container">
  <div class="list-item">Foo</div>
  <div class="list-item">Bar</div>
  <div class="list-item">Baz</div>
  <dom-repeat></dom-repeat>
</div>

Because of that element after reordering any item below its starting position, it goes all the way to the bottom. I found that adding something like this

if (nodes[i].nodeType != 1 || nodes[i] === this.target.node || skippedElements.includes(nodes[i].tagName)) continue;

to line 384 when skippedNodes = [ 'DOM-REPEAT' ] fixes the issue. It would be great to have an option to pass something like that array to Slip and later use it to filter out such elements.