UNPKG

react-resizable-box

Version:

<p align="center"><img src ="https://github.com/bokuweb/react-resizable-box/blob/master/logo.png?raw=true" /></p>

99 lines (90 loc) 2.28 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable react/no-unused-prop-types */ /* eslint-disable react/require-default-props */ /* eslint-disable react/jsx-filename-extension */ exports.default = ResizeHandler; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var styles = { base: { position: 'absolute' }, top: { width: '100%', height: '10px', top: '-5px', left: '0px', cursor: 'row-resize' }, right: { width: '10px', height: '100%', top: '0px', right: '-5px', cursor: 'col-resize' }, bottom: { width: '100%', height: '10px', bottom: '-5px', left: '0px', cursor: 'row-resize' }, left: { width: '10px', height: '100%', top: '0px', left: '-5px', cursor: 'col-resize' }, topRight: { width: '20px', height: '20px', position: 'absolute', right: '-10px', top: '-10px', cursor: 'ne-resize' }, bottomRight: { width: '20px', height: '20px', position: 'absolute', right: '-10px', bottom: '-10px', cursor: 'se-resize' }, bottomLeft: { width: '20px', height: '20px', position: 'absolute', left: '-10px', bottom: '-10px', cursor: 'sw-resize' }, topLeft: { width: '20px', height: '20px', position: 'absolute', left: '-10px', top: '-10px', cursor: 'nw-resize' } }; function ResizeHandler(props) { return _react2.default.createElement('div', { className: props.className, style: _extends({}, styles.base, styles[props.direction], props.replaceStyles || {}), onMouseDown: function onMouseDown(e) { return props.onResizeStart(e, props.direction); }, onTouchStart: function onTouchStart(e) { return props.onResizeStart(e, props.direction); } }); }