2017-07-29 38 views

回答

1

這是一個有點棘手:

https://jsfiddle.net/vtalas/xk73L947/

神奇的是這部分:

paper.on('cell:pointermove', function (cellView, evt) { 

    if (cellView.model.isLink()) { 
    return ; 
    } 

    var parent = cellView.model.getAncestors()[0]; 

    // if we trying to move with embedded cell 
    if (parent) { 

    // cancel move for the child (currently dragged element) 
    cellView.pointerup(evt); 
    var view = paper.findViewByModel(parent); 

    // substitute currently dragged element with the parent 
    paper.sourceView = view; 

    // get parent's position and continue dragging (with the parent, children are updated automaticaly) 
    var localPoint = paper.snapToGrid({ x: evt.clientX, y: evt.clientY }); 
    view.pointerdown(evt, localPoint.x, localPoint.y); 
    } 
}); 
+0

要替換被拖到當前視圖是一個優秀的黑客。謝謝! –

相關問題