Adding and Removing Items

When you add elements to the Shuffle container, notify the Shuffle instance with the
add method. You must add the elements to the DOM yourself. This lets you
control the default (DOM) sort order.

When you want to remove item(s), use remove. This will fade out the item(s)
then remove it from the DOM.




Adding elements

Wherever you add the element in the DOM is where it will show up in the grid (assuming
you’re using the default sort-by-dom-order). With this in mind, you can append,
prepend, or insert elements wherever you need to get them to show up in the right order.

setupEvents() {
  document.querySelector('#append').addEventListener('click', this.onAppendBoxes.bind(this));

  * Create some DOM elements, append them to the shuffle container, then notify
  * shuffle about the new items. You could also insert the HTML as a string.
onAppendBoxes() {
  var elements = this._getArrayOfElementsToAdd();

  elements.forEach(function (element) {
  }, this);

  // Tell shuffle elements have been appended.
  // It expects an array of elements as the parameter.

Removing elements

Shuffle will animate the element away and then remove it from the DOM once it’s finished.
It will then emit the
Shuffle.EventType.REMOVED event with the array of elements in

this.shuffle.remove([element1, element2]);