4
4
import etch from 'etch'
5
5
6
6
import PaneItem from '../util/pane-item'
7
+ import ResizeDetector from 'element-resize-detector'
8
+ import { throttle } from 'underscore-plus'
7
9
import { toView , Toolbar , Button , Icon , BackgroundMessage } from '../util/etch'
8
10
9
11
let defaultPane
@@ -29,8 +31,32 @@ export default class PlotPane extends PaneItem {
29
31
this . ids = [ ]
30
32
this . currentItem = - 1
31
33
34
+ this . resizer = new ResizeDetector ( )
35
+
32
36
etch . initialize ( this )
33
37
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
+ }
34
60
}
35
61
36
62
update ( ) {
@@ -69,7 +95,12 @@ export default class PlotPane extends PaneItem {
69
95
</ div > )
70
96
}
71
97
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 } >
73
104
< Toolbar items = { buttons } >
74
105
< div className = "ink-plot-pane-container fill" >
75
106
{ els }
0 commit comments