From de15e3294b78aea0ba1dbc380f120c30c9a65fac Mon Sep 17 00:00:00 2001 From: rkusa Date: Fri, 15 May 2015 19:24:07 +0200 Subject: [PATCH] add function support for draggable clone option Refs #34 --- touch-dnd.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/touch-dnd.js b/touch-dnd.js index e0435a4..d1ad6fb 100644 --- a/touch-dnd.js +++ b/touch-dnd.js @@ -502,20 +502,24 @@ if (!isHandle) return false } - var el = this.el, handle + var el = this.el, helper if (this.opts.clone) { - handle = this.el.clone() + if (typeof this.opts.clone === 'function') { + helper = this.opts.clone.call(this.el) + } else { + helper = this.el.clone() + if (this.opts.cloneClass) { + helper.addClass(this.opts.cloneClass) + } + } var position = this.el.position() - handle.css('position', 'absolute') + helper.css('position', 'absolute') .css('left', position.left).css('top', position.top) .width(this.el.width()).height(this.el.height()) - if (this.opts.cloneClass) { - handle.addClass(this.opts.cloneClass) - } - handle.insertAfter(this.el) + helper.insertAfter(this.el) } - dragging.start(this, this.el, e, handle) + dragging.start(this, this.el, e, helper) trigger(this.el, 'draggable:start', e, { item: dragging.el }) }