Skip to content

自定义HTML节点无法调整锚点 #1471

Answered by EdwinOlders11
cx88502 asked this question in Q&A
Discussion options

You must be logged in to vote

你需要重写_getDefaultAnchor_而不是_getAnchorStyle_,前者才是改变锚点最基础属性的,比如位置和数量,后者仅仅是样式

class newmodel extends Core.HtmlNodeModel {
    initNodeData(data) { ..... }
    getDefaultAnchor() { //设置锚点的位置、数量、类型和其他基础属性
        const { width, height, x, y, id } = this;
        var newAnchor = [];
        newAnchor.push({
            x: x - width / 2,
            y: height / 2 + 30 + p * 30 + 15,
            type: "left",
            id: `${id}_in${p}`,
        })
        newAnchor.push({
            x: x + width / 2,
            y: y - height / 2 + 15,
            type: "right",
            id: `${id}_out${p}`,
        })
        return newAnchor;
    }
    getAnchorStyle(anchorInfo) { //设置颜色、粗细和线形等
        c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by boyongjiong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants