我正在尝试将widget1
中的一些项目拖放到widget2
的droppable中,但我无法使z-index
正常工作。将拖动项拖过widget2
时,可拖动项目会消失。怎么做到这一点?
更新
main.html中:
<div ng-controller="myCtrl">
<div gridster="gridsterOpts">
<ul><li gridster-item="module" ng-repeat="module in modules" ng-include="module.content"></li></ul>
</div>
drag.html:
<div class="panel panel-default">
<div class="panel-heading">
drag widget
</div>
<div class="panel-body" drag>
<div class="well">drag this</div>
</div>
drop.html:
<div class="panel panel-default">
<div class="panel-heading">
drag widget
</div>
<div class="panel-body" drop>
<div class="well">drop here</div>
</div>
draggable指令:
function drag() {
return {
restrict: "A",
scope: {},
link: function (scope, elem, attrs) {
elem.draggable({
zIndex: 1000,
helper: 'clone'
});
}
}
}
MyCtrl:
function myCtrl($scope) {
$scope.gridsterOpts = {
columns: 6, // the width of the grid, in columns
pushing: true, // whether to push other items out of the way on move or resize
floating: false, // whether to automatically float items up so they stack (you can temporarily disable if you are adding unsorted items with ng-repeat)
swapping: false, // whether or not to have items of the same size switch places instead of pushing down if they are the same size
width: 'auto', // can be an integer or 'auto'. 'auto' scales gridster to be the full width of its containing element
colWidth: 'auto', // can be an integer or 'auto'. 'auto' uses the pixel width of the element divided by 'columns'
rowHeight: 'match', // can be an integer or 'match'. Match uses the colWidth, giving you square widgets.
margins: [10, 10], // the pixel distance between each widget
outerMargin: true, // whether margins apply to outer edges of the grid
isMobile: false, // stacks the grid items if true
mobileBreakPoint: 600, // if the screen is not wider that this, remove the grid layout and stack the items
mobileModeEnabled: true, // whether or not to toggle mobile mode when screen width is less than mobileBreakPoint
minColumns: 1, // the minimum columns the grid must have
minRows: 2, // the minimum height of the grid, in rows
maxRows: 20,
defaultSizeX: 2, // the default width of a gridster item, if not specifed
defaultSizeY: 1, // the default height of a gridster item, if not specified
minSizeX: 1, // minimum column width of an item
maxSizeX: null, // maximum column width of an item
minSizeY: 1, // minumum row height of an item
maxSizeY: null, // maximum row height of an item
resizable: {
enabled: true,
handles: ['n', 'e', 's', 'w', 'ne', 'se', 'sw', 'nw'],
start: function (event, $element, widget) { }, // optional callback fired when resize is started,
resize: function (event, $element, widget) { }, // optional callback fired when item is resized,
stop: function (event, $element, widget) { } // optional callback fired when item is finished resizing
},
draggable: {
scroll: false,
enabled: true, // whether dragging items is supported
handle: ".panel-heading", // optional selector for resize handle
start: function (event, $element, widget) { }, // optional callback fired when drag is started,
drag: function (event, $element, widget) { }, // optional callback fired when item is moved,
stop: function (event, $element, widget) { } // optional callback fired when item is finished dragging
}
};
$scope.modules = [
{ sizeX: 1, sizeY: 2, row: 0, col: 0, content: "views/modules/drag.html" },
{ sizeX: 1, sizeY: 2, row: 0, col: 2, content: "views/modules/drop.html" }
];
};
答案 0 :(得分:0)
当窗口小部件未处于拖动状态时,只需重置gridster项z-index:
.gridster-item:not(.gridster-item-moving) {
//drop z-index to make it possible to set higher than 2 z-index for widget elements
z-index: initial;
}