
import RayDragable from 'ray-dragable';

const defaultOptions = {
  ghostClass: 'amos-dragable-ghost',
  chosenClass: 'amos-dragable-chosen',
  dragClass: 'amos-dragable-drager',
  animation: 300
};

// @author ilex.h
class DragableDecorator {
  /**
   *
   * @param {any} componentBackingInstance
   * @param {object} options
   *  {
   *    handle: '.class' // Restricts dragable start click/touch to the specified element
   *  }
   * @static
   *
   * @memberOf DragableDecorator
   */
  static dragableContainersDecorator = (componentBackingInstance, options) => {
    // check if backing instance not null
    if (componentBackingInstance) {
      const _opts = Object.assign({}, defaultOptions, options);
      RayDragable.create(componentBackingInstance, _opts);
    }
  };

  /**
   * @param {any} componentBackingInstance
   * @param {object} options
   *   {
   *     draggable: 'div', // Specifies which items inside the element should be dragable
   *     group: 'shared'
   *   };
   *
   * @static
   *
   * @memberOf DragableDecorator
   */
  static dragableGroupDecorator = (componentBackingInstance, options) => {
    // check if backing instance not null
    if (componentBackingInstance) {
      const _opts = Object.assign({}, defaultOptions, options);
      RayDragable.create(componentBackingInstance, _opts);
    }
  }
}

export default DragableDecorator;
