import React from 'react'; import Resizable from '../lib/Resizable'; import ResizableBox from '../lib/ResizableBox'; import 'style-loader!css-loader!../css/styles.css'; /* global __VERSION__, __GIT_TAG__, __GIT_COMMIT__ */ // Update the version badge in the header function updateVersionBadge() { const badge = document.getElementById('version-badge'); if (badge) { const version = __GIT_TAG__ || `v${__VERSION__}`; badge.textContent = version + (__GIT_COMMIT__ ? ` (${__GIT_COMMIT__})` : ''); badge.href = `https://github.com/react-grid-layout/react-resizable/releases/tag/${__GIT_TAG__ || __VERSION__}`; } } if (typeof document !== 'undefined') { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', updateVersionBadge); } else { updateVersionBadge(); } } const CustomResizeHandle = React.forwardRef((props, ref) => { const {handleAxis, ...restProps} = props; return (
); }); export default class ExampleLayout extends React.Component<{}, {width: number, height: number}> { state = { width: 200, height: 200, absoluteWidth: 200, absoluteHeight: 200, absoluteLeft: 0, absoluteTop: 0, }; onResetClick = () => { this.setState({ width: 200, height: 200, absoluteWidth: 200, absoluteHeight: 200 }); }; // On top layout onFirstBoxResize = (event, {element, size, handle}) => { this.setState({width: size.width, height: size.height}); }; // On bottom layout. Used to resize the center element around its flex parent. onResizeAbsolute = (event, {element, size, handle}) => { this.setState((state) => { let newLeft = state.absoluteLeft; let newTop = state.absoluteTop; const deltaHeight = size.height - state.absoluteHeight; const deltaWidth = size.width - state.absoluteWidth; if (handle[0] === 'n') { newTop -= deltaHeight; } else if (handle[0] === 's') { newTop += deltaHeight; } if (handle[handle.length - 1] === 'w') { newLeft -= deltaWidth; } else if (handle[handle.length - 1] === 'e') { newLeft += deltaWidth; } return { absoluteWidth: size.width, absoluteHeight: size.height, absoluteLeft: newLeft, absoluteTop: newTop, }; }); }; render() { return (transform: scale(n), be sure to pass the same n
as the transformScale property. This layout has scale(0.75).