Skip to content

Commit

Permalink
Tuch#30 Add handle option to dnd-sortable-opts.
Browse files Browse the repository at this point in the history
Using: dnd-sortable-opts="{handle: '\'.handle\''}" - note to use double quoting.
  • Loading branch information
mikhail.kopylov committed Sep 1, 2015
1 parent 3432fa6 commit c323d9f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/directives/dndSortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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) + '></' + tag + '>';
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit c323d9f

Please sign in to comment.