Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Adds and removes node with skipping undo

$
0
0

@HJOON.KIM wrote:

Walter, another question.
I have many questions today, sorry and thank you.

I have this code.
I call it when I double-clicked or right-click somewhere in background using type = ‘zoomin’ and type = ‘zoomout’.

    function markZoomAt(point, type = "zoomin", color = null) {
        if (!(new Set(["zoomin", "zoomout", "pacman"]).has(type)))
            return;

        var data = {
            category:"Icon",
            geo:type,
            loc:go.Point.stringify(new go.Point(point.x - _IconNodeCircleSize / 2, point.y - _IconNodeCircleSize / 2)),
        };

        if (color != null) {
            data.color = color;
        }

        var oldskips = _d.skipsUndoManager;
        _d.skipsUndoManager = true;
        _d.startTransaction("draw focus marker");

        _d.model.addNodeData(data);

        _d.commitTransaction("draw focus marker");
        _d.skipsUndoManager = oldskips;

        setTimeout(function() {
            var oldskips = _d.skipsUndoManager;
            _d.skipsUndoManager = true;
            _d.startTransaction("remove focus marker");

            _d.model.removeNodeData(data);

            _d.commitTransaction("remove focus marker");
            _d.skipsUndoManager = oldskips;
        }, 2000);
    }

This code adds a node and removes it after 2 seconds.
And I expect this code makes the model not to be ‘modified’ status.
But it’s not working.

How should I fix it?

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles