我正在为我的客户做拖放功能。我已经为拖放实现了拖放,但是在dragular或任何其他为拖放提供的库中没有提供多元素拖放。
请建议我如何选择和拖放多个元素在角或任何其他javascript库,也应该与触摸设备兼容。
提前谢谢。
注:我们可以使用拖曳多次拖放。?
更新(30/11/2016):把我的要求加起来一点。如何限制拖放区域中元素的冗余。
解释:
发布于 2016-11-15 16:43:21
你的意思是多个单独的拖放?就像用一个手指拉一个元素,用另一个手指拉第二个元素?
这不是dragula支持的,也不是dragular支持的,但我正在开发新的库,这是可能的,但它现在仍在进行中:/
我不知道还有其他图书馆支持它。
编辑(27.11.16):
我更新了你的钢笔http://codepen.io/luckylooke/pen/zodmEO
angular.module("testDnD", ["dragularModule"]).
controller("test", ['$scope', 'dragularService', function($scope, dragularService) {
$scope.selected = [];
$scope.filter = [];
$scope.testObj = [{...}];
$scope.modelClickData = function(test) {
console.log(test);
$scope.popdata = test;
};
$scope.modelSelect = function(test) {
test.selected = !test.selected;
if (test.selected)
$scope.selected.push(test);
else
$scope.selected.splice($scope.selected.indexOf(test), 1);
// console.log('selected', test);
};
var containerLeft = document.querySelector('#thumbnailTST');
var containerRight = document.querySelector('#filler');
dragularService.cleanEnviroment();
dragularService([containerLeft, containerRight], {
copy: true,
containersModel: [$scope.testObj, $scope.filter],
scope: $scope
});
$scope.$on('dragularcloned', function() {
var mirror = $('.gu-mirror');
if ($scope.selected.length > 1 && mirror.length) { // is multiple drag
mirror.addClass('multipledrag');
}
});
$scope.$on('dragulardrop', function(e, el, targetcontainer, sourcecontainer, conmodel, elindex, targetmodel, dropindex) {
if ($scope.selected.length > 1) { // is multiple drag
$scope.selected.forEach(function(item) {
if (item != $scope.testObj[elindex]) {
var clone = {};
clone = $.extend(true, clone, item);
delete clone.$$hashKey;
$scope.filter.splice(++dropindex, 0, clone);
}
});
}
console.log($scope.filter);
});
}])发布于 2016-11-14 18:46:39
这是你问题的答案。jQuery Sortable - Select and Drag Multiple List Items
我认为使用jQuery进行拖放是个好主意。我用的是这个而且是工作的。这里你有个例子
jsfiddle.net/hQnWG/614/
https://stackoverflow.com/questions/40595459
复制相似问题