Skip to content

Commit 20b29bd

Browse files
authored
Merge pull request #250 from JunoLab/sp/plotpaneresizing
prevent pointer events while resizing plot pane
2 parents fbf41c3 + 35b86c3 commit 20b29bd

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

lib/console/console.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { WebLinksAddon } from 'xterm-addon-web-links'
1010
import { FitAddon } from 'xterm-addon-fit'
1111
import TerminalElement from './view'
1212
import PaneItem from '../util/pane-item'
13-
import ResizeDetector from 'element-resize-detector'
1413
import { debounce, throttle } from 'underscore-plus'
1514
import { closest } from './helpers'
1615
import { openExternal } from 'shell'

lib/plots/pane.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import etch from 'etch'
55

66
import PaneItem from '../util/pane-item'
7+
import ResizeDetector from 'element-resize-detector'
8+
import { throttle } from 'underscore-plus'
79
import { toView, Toolbar, Button, Icon, BackgroundMessage } from '../util/etch'
810

911
let defaultPane
@@ -29,8 +31,32 @@ export default class PlotPane extends PaneItem {
2931
this.ids = []
3032
this.currentItem = -1
3133

34+
this.resizer = new ResizeDetector()
35+
3236
etch.initialize(this)
3337
this.element.setAttribute('tabindex', -1)
38+
39+
this.resizer.listenTo(this.element, throttle(() => this.resizing(true), 150))
40+
this.resizerTimeout = null
41+
}
42+
43+
resizing(isResizing) {
44+
if (this.resizerTimeout) {
45+
clearTimeout(this.resizerTimeout)
46+
}
47+
48+
const shouldUpdate = isResizing !== this.isResizing
49+
this.isResizing = isResizing
50+
if (shouldUpdate) {
51+
etch.update(this)
52+
}
53+
54+
if (isResizing) {
55+
this.resizerTimeout = setTimeout(() => this.resizing(false), 200)
56+
} else {
57+
clearTimeout(this.resizerTimeout)
58+
this.resizerTimeout = null
59+
}
3460
}
3561

3662
update() {
@@ -69,7 +95,12 @@ export default class PlotPane extends PaneItem {
6995
</div>)
7096
}
7197

72-
return <span className='ink-plot-pane'>
98+
let cn = 'ink-plot-pane'
99+
if (this.isResizing) {
100+
cn += ' is-resizing'
101+
}
102+
103+
return <span className={cn}>
73104
<Toolbar items={buttons}>
74105
<div className="ink-plot-pane-container fill">
75106
{els}

styles/plot-pane.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
height: 100%;
1010
width: 100%;
1111
}
12+
13+
&.is-resizing {
14+
pointer-events: none;
15+
}
1216
}

0 commit comments

Comments
 (0)