Skip to content

Commit 2ac39df

Browse files
committed
Stop resizing on certain situations
1 parent 0bcf212 commit 2ac39df

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ui/arduino/store.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ async function store(state, emitter) {
5555
state.panelHeight = PANEL_CLOSED
5656
state.resizePanel = function(e) {
5757
state.panelHeight = (PANEL_CLOSED/2) + document.body.clientHeight - e.clientY
58-
state.savedPanelHeight = state.panelHeight
58+
if (state.panelHeight <= PANEL_CLOSED) {
59+
state.savedPanelHeight = PANEL_DEFAULT
60+
} else {
61+
state.savedPanelHeight = state.panelHeight
62+
}
5963
emitter.emit('render')
6064
}
6165

@@ -195,13 +199,15 @@ async function store(state, emitter) {
195199

196200
// PANEL
197201
emitter.on('open-panel', () => {
202+
emitter.emit('stop-resizing-panel')
198203
state.panelHeight = state.savedPanelHeight
199204
emitter.emit('render')
200205
setTimeout(() => {
201206
state.cache(XTerm, 'terminal').resizeTerm()
202207
}, 200)
203208
})
204209
emitter.on('close-panel', () => {
210+
emitter.emit('stop-resizing-panel')
205211
state.savedPanelHeight = state.panelHeight
206212
state.panelHeight = 0
207213
emitter.emit('render')
@@ -212,6 +218,13 @@ async function store(state, emitter) {
212218
emitter.on('start-resizing-panel', () => {
213219
log('start-resizing-panel')
214220
window.addEventListener('mousemove', state.resizePanel)
221+
// Stop resizing when mouse leaves window or enters the tabs area
222+
document.body.addEventListener('mouseleave', () => {
223+
emitter.emit('stop-resizing-panel')
224+
}, { once: true })
225+
document.querySelector('#tabs').addEventListener('mouseenter', () => {
226+
emitter.emit('stop-resizing-panel')
227+
}, { once: true })
215228
})
216229
emitter.on('stop-resizing-panel', () => {
217230
log('stop-resizing-panel')

0 commit comments

Comments
 (0)