mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 07:02:39 +00:00
Limit position to min/max window limits
This commit is contained in:
@@ -4,9 +4,6 @@ const createClass = require('create-react-class');
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
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({
|
const SplitPane = createClass({
|
||||||
getDefaultProps : function() {
|
getDefaultProps : function() {
|
||||||
return {
|
return {
|
||||||
@@ -43,8 +40,9 @@ const SplitPane = createClass({
|
|||||||
},
|
},
|
||||||
handleMove : function(e){
|
handleMove : function(e){
|
||||||
if(!this.state.isDragging) return;
|
if(!this.state.isDragging) return;
|
||||||
const minWidth = window.innerWidth * (MIN_DRAG_WIDTH_PCT / 100);
|
|
||||||
const maxWidth = window.innerWidth * (MAX_DRAG_WIDTH_PCT / 100);
|
const minWidth = 1;
|
||||||
|
const maxWidth = window.innerWidth - 13;
|
||||||
const newSize = Math.min(maxWidth, Math.max(minWidth, e.pageX));
|
const newSize = Math.min(maxWidth, Math.max(minWidth, e.pageX));
|
||||||
this.setState({
|
this.setState({
|
||||||
size : newSize
|
size : newSize
|
||||||
|
|||||||
Reference in New Issue
Block a user