Skip to content

Commit c19d0b7

Browse files
authored
Query manager panel resizes smoothly (ToolJet#1812)
* jumbing problem fixed with smooth transition * now query panel can be drag using the border * removed css transition
1 parent 7e24ad0 commit c19d0b7

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

frontend/src/Editor/Editor.jsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Editor extends React.Component {
7272
allComponentTypes: componentTypes,
7373
isQueryPaneDragging: false,
7474
queryPaneHeight: 70,
75+
isTopOfQueryPane: false,
7576
isLoading: true,
7677
users: null,
7778
appId,
@@ -117,8 +118,21 @@ class Editor extends React.Component {
117118
}
118119

119120
onMouseMove = (e) => {
121+
const componentTop = Math.round(this.queryPaneRef.current.getBoundingClientRect().top);
122+
const clientY = e.clientY;
123+
124+
if ((clientY >= componentTop) & (clientY <= componentTop + 5)) {
125+
this.setState({
126+
isTopOfQueryPane: true,
127+
});
128+
} else {
129+
this.setState({
130+
isTopOfQueryPane: false,
131+
});
132+
}
133+
120134
if (this.state.isQueryPaneDragging) {
121-
let queryPaneHeight = (e.clientY / window.screen.height) * 100;
135+
let queryPaneHeight = (clientY / window.innerHeight) * 100;
122136

123137
if (queryPaneHeight > 95) queryPaneHeight = 100;
124138
if (queryPaneHeight < 4.5) queryPaneHeight = 4.5;
@@ -965,21 +979,13 @@ class Editor extends React.Component {
965979
ref={this.queryPaneRef}
966980
onTouchEnd={this.onMouseUp}
967981
onMouseDown={this.onMouseDown}
968-
className="query-pane"
969-
style={{
970-
height: `calc(100% - ${this.state.queryPaneHeight - 1}%)`,
971-
background: 'transparent',
972-
border: 0,
973-
cursor: 'row-resize',
974-
}}
975-
></div>
976-
<div
977982
className="query-pane"
978983
style={{
979984
height: `calc(100% - ${this.state.queryPaneHeight}%)`,
980985
width: !showLeftSidebar ? '85%' : '',
981986
left: !showLeftSidebar ? '0' : '',
982-
cursor: this.state.isQueryPaneDragging ? 'row-resize' : 'default',
987+
// transition: 'height 0.3s ease-in-out',
988+
cursor: this.state.isQueryPaneDragging || this.state.isTopOfQueryPane ? 'row-resize' : 'default',
983989
}}
984990
>
985991
<div className="row main-row">

0 commit comments

Comments
 (0)