3
3
4
4
import etch from 'etch' ;
5
5
import { prewalk , postwalk , prefor } from './tree.js' ;
6
- import { Etch , Tip , Button , toView } from '../util/etch.js' ;
6
+ import { Etch , Button , toView } from '../util/etch.js' ;
7
7
8
8
function clamp ( x , min , max ) {
9
9
return Math . min ( Math . max ( x , min ) , max )
@@ -26,12 +26,12 @@ function dims(tree) {
26
26
left += ch . width ;
27
27
} ) ;
28
28
// Centre align children
29
- chwidth = parent . children . map ( ( { width} ) => width ) . reduce ( ( a , b ) => a + b , 0 ) ;
29
+ const chwidth = parent . children . map ( ( { width} ) => width ) . reduce ( ( a , b ) => a + b , 0 ) ;
30
30
parent . children . forEach ( ch => ch . left += ( parent . width - chwidth ) / 2 ) ;
31
31
return parent ;
32
32
} ) ;
33
33
// Scale total height to 100%
34
- let max = postwalk ( tree , ( { height, children} ) =>
34
+ const max = postwalk ( tree , ( { height, children} ) =>
35
35
Math . max ( height , ...children . map ( x => x + height ) ) ) ;
36
36
prewalk ( tree , ( node ) => {
37
37
node . top /= max ;
@@ -170,7 +170,7 @@ export class Pannable extends Etch {
170
170
this . toolbar = this . toolbar . concat ( this . item . toolbar )
171
171
}
172
172
173
- let style = { position :'relative' , height :'inherit' , width :'inherit' , transformOrigin : '0px 0px' }
173
+ const style = { position :'relative' , height :'inherit' , width :'inherit' , transformOrigin : '0px 0px' }
174
174
175
175
if ( this . zoomstrategy == 'width' ) {
176
176
style . transform = 'translate(' + this . left + 'px,' + this . top + 'px)'
@@ -211,22 +211,27 @@ export class Pannable extends Etch {
211
211
212
212
class NodeView extends Etch {
213
213
render ( ) {
214
- let { height, width, top, left, onclick, onmouseover, onmouseout} = this . props ;
215
- return < Clickable onclick = { onclick } > < div className = 'node' { ...{ onmouseover, onmouseout} } style = { {
216
- height : 100 * height + '%' ,
217
- width : 100 * width + '%' ,
218
- top : 100 * top + '%' ,
219
- left : 100 * left + '%'
220
- } } >
221
- < div > < div > </ div > </ div >
222
- </ div > </ Clickable > ;
214
+ const { height, width, top, left, onclick, onmouseover, onmouseout } = this . props ;
215
+ return < Clickable onclick = { onclick } >
216
+ < div className = 'node' { ...{ onmouseover, onmouseout} } style = { {
217
+ height : 100 * height + '%' ,
218
+ width : 100 * width + '%' ,
219
+ top : 100 * top + '%' ,
220
+ left : 100 * left + '%'
221
+ } } >
222
+ < div >
223
+ < div >
224
+ </ div >
225
+ </ div >
226
+ </ div >
227
+ </ Clickable > ;
223
228
}
224
229
}
225
230
226
231
export default class Canopy extends Etch {
227
- update ( { data} ) { }
232
+ update ( { data } ) { }
228
233
render ( ) {
229
- let nodes = [ ] ;
234
+ const nodes = [ ] ;
230
235
prefor ( dims ( this . props . data ) , node => nodes . push ( < NodeView { ...node } /> ) ) ;
231
236
return < div className = "ink-canopy" >
232
237
{ nodes }
0 commit comments