MDL-34328: block dragdrop - performance rewrite
Use YUI's DragDrop delegates for block dragdrop - one per block region - rather than initialising a Drag object for each individual block.
This commit is contained in:
committed by
Andrew Robert Nicols
parent
a573a5157e
commit
65c8ccc02e
Vendored
+14
-11
@@ -68,23 +68,26 @@ YUI.add('moodle-core-blocks', function(Y) {
|
||||
padding: '40 240 40 240'
|
||||
});
|
||||
|
||||
// Make each div element in the list of blocks draggable
|
||||
var del = new Y.DD.Delegate({
|
||||
container: blockregionnode,
|
||||
nodes: '.'+CSS.BLOCK,
|
||||
target: true,
|
||||
handles: ['.'+CSS.HEADER],
|
||||
dragConfig: {groups: this.groups}
|
||||
});
|
||||
del.dd.plug(Y.Plugin.DDProxy, {
|
||||
// Don't move the node at the end of the drag
|
||||
moveOnEnd: false
|
||||
});
|
||||
del.dd.plug(Y.Plugin.DDWinScroll);
|
||||
|
||||
var blocklist = blockregionnode.all('.'+CSS.BLOCK);
|
||||
blocklist.each(function(blocknode) {
|
||||
var move = blocknode.one('a.'+CSS.EDITINGMOVE);
|
||||
if (move) {
|
||||
move.remove();
|
||||
blocknode.one('.'+CSS.HEADER).setStyle('cursor', 'move');
|
||||
// Make each div element in the list of blocks draggable
|
||||
var dd = new Y.DD.Drag({
|
||||
node: blocknode,
|
||||
groups: this.groups,
|
||||
// Make each div a Drop target too
|
||||
target: true,
|
||||
handles: ['.'+CSS.HEADER]
|
||||
}).plug(Y.Plugin.DDProxy, {
|
||||
// Don't move the node at the end of the drag
|
||||
moveOnEnd: false
|
||||
}).plug(Y.Plugin.DDWinScroll);
|
||||
}
|
||||
}, this);
|
||||
}, this);
|
||||
|
||||
Reference in New Issue
Block a user