blob: 00766496ea9083aa18a3ec856f731ed7a7b2b2ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import PropTypes from "prop-types";
import React from "react";
import {Image} from "react-konva";
class ImageComponent extends React.Component {
static propTypes = {
src: PropTypes.string.isRequired,
x: PropTypes.number.isRequired,
y: PropTypes.number.isRequired,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
opacity: PropTypes.number.isRequired,
};
state = {
image: null
};
componentDidMount() {
const image = new window.Image();
image.src = this.props.src;
image.onload = () => this.setState({image});
}
render() {
return (
<Image
image={this.state.image}
x={this.props.x}
y={this.props.y}
width={this.props.width}
height={this.props.height}
opacity={this.props.opacity}
/>
)
}
}
export default ImageComponent;
|