0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Add limits to central divider position

This commit is contained in:
G.Ambatte
2021-10-19 14:39:51 +13:00
parent e9b9c87188
commit a2a6a3d3f6

View File

@@ -4,6 +4,9 @@ const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const MIN_DRAG_WIDTH_PCT = 10; // How close the divider can get to the left of the screen (as a percentage of total screen width) before stopping
const MAX_DRAG_WIDTH_PCT = 90; // How close the divider can get to the right of the screen (as a percentage of total screen width) before stopping
const SplitPane = createClass({
getDefaultProps : function() {
return {
@@ -40,8 +43,11 @@ const SplitPane = createClass({
},
handleMove : function(e){
if(!this.state.isDragging) return;
const minWidth = window.innerWidth * (MIN_DRAG_WIDTH_PCT / 100);
const maxWidth = window.innerWidth * (MAX_DRAG_WIDTH_PCT / 100);
const newSize = Math.min(maxWidth, Math.max(minWidth, e.pageX));
this.setState({
size : e.pageX
size : newSize
});
},
/*