Skip to content

RectResize.model 可以通过除了监听缩放事件以外的途径通过缩放触发一个函数吗 #1288

Answered by wumail
cpf23333 asked this question in Q&A
Discussion options

You must be logged in to vote

需要手动调用一下,大概是这个意思,类里面的任何方法都可以,不一定是resize

lf.on('node:resize', ({ oldNodeSize, newNodeSize }: any) => {
 const { id } = newNodeSize
 lf.getNodeModelById(id).resize(newNodeSize)
})

class model extends GroupNode.model{
  ...
  resize(newNodeSize){
    const { x , y, width, height } = newNodeSize
    this.x = x + width / 2 
    this.y = y + height / 2
    // do anything you want
  }
  ...
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@cpf23333
Comment options

@wumail
Comment options

Answer selected by cpf23333
@cpf23333
Comment options

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