From c323d9f1d9f1c26643eb9d8cfde9b3d4244ff4b2 Mon Sep 17 00:00:00 2001 From: "mikhail.kopylov" Date: Tue, 1 Sep 2015 16:40:49 +0300 Subject: [PATCH] #30 Add handle option to dnd-sortable-opts. Using: dnd-sortable-opts="{handle: '\'.handle\''}" - note to use double quoting. --- src/directives/dndSortable.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/directives/dndSortable.js b/src/directives/dndSortable.js index 11d9dd2..483a697 100644 --- a/src/directives/dndSortable.js +++ b/src/directives/dndSortable.js @@ -25,7 +25,7 @@ module.directive('dndSortable', ['$parse', '$compile', function($parse, $compile } var opts = angular.extend({ - layer: "'common'", + layer: "'common'" }, $parse(tAttrs.dndSortableOpts)()); var attrs = { @@ -34,17 +34,18 @@ module.directive('dndSortable', ['$parse', '$compile', function($parse, $compile 'dnd-draggable-opts': joinObj({ helper: "'clone'", useAsPoint: true, - layer: opts.layer + layer: opts.layer, + handle: opts.handle }), 'dnd-droppable': '', 'dnd-droppable-opts': joinObj({ - layer: opts.layer, + layer: opts.layer }), 'dnd-on-dragstart': '$$onDragStart($api, $dropmodel, $dragmodel)', 'dnd-on-dragend': '$$onDragEnd($api, $dropmodel, $dragmodel)', 'dnd-on-dragover': '$$onDragOver($api, $dropmodel, $dragmodel)', 'dnd-on-drag': '$$onDrag($api, $dropmodel, $dragmodel)', - 'dnd-model': '{item: ' + match[1] + ', list: ' + match[2] + ', index: $index}', + 'dnd-model': '{item: ' + match[1] + ', list: ' + match[2] + ', index: $index}' }; return '<' + tag + ' ' + joinAttrs(attrs) + '>'; @@ -113,6 +114,10 @@ module.directive('dndSortable', ['$parse', '$compile', function($parse, $compile }; scope.$$onDragOver = function(api, dropmodel, dragmodel) { + var isDraggingNow = angular.isDefined(api.$sortable); + if (!isDraggingNow) { + return; + } var halfway = isHalfway(api.getDragTarget(), api.getBorderedAxis()); halfway ? parentNode.insertBefore(placeholder[0], element[0].nextSibling) : parentNode.insertBefore(placeholder[0], element[0]);