Skip to content

Commit

Permalink
Merge pull request Tuch#31 from mih-kopylov/master
Browse files Browse the repository at this point in the history
Tuch#30 Add handle option to dnd-sortable-opts.
  • Loading branch information
Tuch committed Sep 10, 2015
2 parents 77667a7 + df54563 commit 8d26561
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 @@ -61,7 +61,7 @@ module.directive('dndSortable', ['$parse', '$compile', function($parse, $compile
}

var opts = angular.extend({
layer: "common",
layer: "common"
}, $parse(tAttrs.dndSortableOpts)());

console.log(opts);
Expand All @@ -72,17 +72,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 @@ -127,6 +128,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(api.placeholder[0], element[0].nextSibling) : parentNode.insertBefore(api.placeholder[0], element[0]);
Expand Down

0 comments on commit 8d26561

Please sign in to comment.