Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. class App extends React.Component {
  2. state = {
  3. width: 200,
  4. left: 0
  5. };
  6. startX = 0;
  7. startWidth = 0;
  8.  
  9. render() {
  10. return (
  11. <div className="layoutRoot">
  12. <Resizable
  13. className="box"
  14. width={this.state.width}
  15. onResizeStart={(mouseEvent, node) => {
  16. this.startX = mouseEvent.clientX;
  17. this.startWidth = node.size.width;
  18. }}
  19. onResize={mouseEvent => {
  20. const offsetWidth = this.startX - mouseEvent.clientX;
  21.  
  22. this.setState({
  23. width: this.startWidth + offsetWidth,
  24. left: this.startX - offsetWidth
  25. });
  26. }}
  27. resizeHandles={["w"]}
  28. >
  29. <div
  30. className="box-left"
  31. style={{
  32. width: this.state.width + "px",
  33. left: this.state.left + "px"
  34. }}
  35. >
  36. <span className="text">{"<Resizable Left>"}</span>
  37. </div>
  38. </Resizable>
  39. </div>
  40. );
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement