<commit_before>/**
 * Enable drag and drop of blocks and groups.
 * @private
 */
cg.Renderer.prototype._renderDrag = function () {
    var renderer = this;
    return d3.behavior.drag()
        .on("dragstart", function () {
            var node = d3.select(this);
            renderer.addEntityToSelection(node, !d3.event.sourceEvent.shiftKey);
            var selected = renderer.getSelectedEntities();
            selected.each(function (entity) {
                if (entity.parent !== renderer._graph) {
                    renderer._graph.moveEntity(entity, renderer._graph);
                }
                entity.emit("reorder");
                if (entity instanceof cg.Group) {
                    entity.forEachChild(function (childEntity) {
                        if (childEntity instanceof cg.Group) {
                            childEntity.emit("reorder");
                        }
                    });
                }
            });
            pandora.preventCallback(d3.event.sourceEvent);
        })
        .on("drag", function () {
            var selected = renderer.getSelectedEntities();
            selected.each(function (entity) {
                entity.position.x += d3.event.dx;
                entity.position.y += d3.event.dy;
                entity.emit("move");
                if (entity instanceof cg.Group) {
                    entity.forEachChild(function (childEntity) {
                        childEntity.emit("move");
                    });
                }
            });
        })
        .on("dragend", function () {
            renderer._updateRendererCollisions();
        });
};<commit_msg>Added drop<commit_after>/**
 * Enable drag and drop of blocks and groups.
 * @private
 */
cg.Renderer.prototype._renderDrag = function () {
    var renderer = this;
    return d3.behavior.drag()
        .on("dragstart", function () {
            var node = d3.select(this);
            renderer.addEntityToSelection(node, !d3.event.sourceEvent.shiftKey);
            var selected = renderer.getSelectedEntities();
            selected.each(function (entity) {
                if (entity.parent !== renderer._graph) {
                    renderer._graph.moveEntity(entity, renderer._graph);
                }
                entity.emit("reorder");
                if (entity instanceof cg.Group) {
                    entity.forEachChild(function (childEntity) {
                        if (childEntity instanceof cg.Group) {
                            childEntity.emit("reorder");
                        }
                    });
                }
            });
            pandora.preventCallback(d3.event.sourceEvent);
        })
        .on("drag", function () {
            var selected = renderer.getSelectedEntities();
            selected.each(function (entity) {
                entity.position.x += d3.event.dx;
                entity.position.y += d3.event.dy;
                entity.emit("move");
                if (entity instanceof cg.Group) {
                    entity.forEachChild(function (childEntity) {
                        childEntity.emit("move");
                    });
                }
            });
        })
        .on("dragend", function () {
            renderer._updateRendererCollisions();
            var selected = renderer.getSelectedEntities();
            selected.each(function (entity) {
                var dropBox = new pandora.Box2(entity.absolutePosition.x, entity.absolutePosition.y, this.getBBox().width, this.getBBox().height);
                var possible = renderer._getEntitiesInArea(dropBox);
                possible.each(function (possibleEntity) {
                    //noinspection JSPotentiallyInvalidUsageOfThis
                    var possibleDropBox = new pandora.Box2(possibleEntity.absolutePosition.x, possibleEntity.absolutePosition.y, this.getBBox().width, this.getBBox().height);
                    if (possibleEntity !== entity && possibleDropBox.contain(dropBox)) {
                        renderer._graph.moveEntity(entity, possibleEntity);
                    }
                });
            });
        });
};
{'fraction_non_alphanumeric': 0.11392710596186338, 'fraction_numerical': 0.0033791938209027277, 'mean_word_length': 1.4948826008428657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7569552', 'n_tokens_mistral': 1033, 'n_tokens_neox': 993, 'n_words': 171}