使用react-konva翻转图像 [英] Flip Image with react-konva

查看:204
本文介绍了使用react-konva翻转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 https://github.com/lavrton/react-konva

如何翻转图像(水平或垂直)我正在使用此功能,但不起作用:

How can I flip an image (horizontally or vertically) I am using this function, but it is not working:

  flip = direction => {
    this.setState({
      width: -this.state.width
    })
  }

推荐答案

最好使用scale属性:

It is better to use scale property:

<Image image={this.state.image} scaleY={-1} y={200}/>

因此,在您的状态下,应存储具有1或-1值的 scale 属性,

So in your state, you should store scale property with 1 or -1 values,

https://codesandbox.io/s/v6yk2j2w0l

这篇关于使用react-konva翻转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆