Skip to content

Commit e1e3074

Browse files
committed
various plot related fixes
1 parent de45fe3 commit e1e3074

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

lib/plots/canopy.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,22 @@ export class Pannable extends Etch {
7777
this.left = 0
7878
this.top = 0
7979

80+
this.isLoaded = false
81+
8082
// force update, so readAfterUpdate gets executed
8183
this.update()
82-
item.onload = () => {
83-
etch.update(this).then(() => {
84-
this.setInitialScale(item)
85-
etch.update(this)
86-
})
84+
if (item && item.nodeName && item.nodeName.toLowerCase() === 'img') {
85+
item.onload = () => {
86+
etch.update(this).then(() => {
87+
this.setInitialScale(item)
88+
this.isLoaded = true
89+
etch.update(this)
90+
})
91+
}
92+
} else {
93+
this.isLoaded = true
8794
}
95+
this.update()
8896
}
8997

9098
readAfterUpdate () {
@@ -120,7 +128,7 @@ export class Pannable extends Etch {
120128
}
121129

122130
zoom(e, amount) {
123-
const zoom = amount || Math.pow(0.99, e.deltaY)
131+
const zoom = amount || Math.pow(e.shiftKey ? 0.99 : 0.999, e.deltaY)
124132

125133
if (zoom*this.scale > this.maxScale || zoom*this.scale < this.minScale) return
126134

@@ -160,14 +168,19 @@ export class Pannable extends Etch {
160168
this.toolbar = this.toolbar.concat(this.item.toolbar)
161169
}
162170

163-
let position = {position:'relative', height:'inherit', width:'inherit', transformOrigin: '0px 0px'}
171+
let style = {position:'relative', height:'inherit', width:'inherit', transformOrigin: '0px 0px'}
164172

165173
if (this.zoomstrategy == 'width') {
166-
position.transform = 'translate('+this.left+'px,'+this.top+'px)'
167-
position.height = scale
168-
position.width = scale
174+
style.transform = 'translate('+this.left+'px,'+this.top+'px)'
175+
style.height = scale
176+
style.width = scale
169177
} else if (this.zoomstrategy == 'transform') {
170-
position.transform = 'translate('+this.left+'px,'+this.top+'px) scale('+this.scale+')'
178+
style.transform = 'translate('+this.left+'px,'+this.top+'px) scale('+this.scale+')'
179+
}
180+
if (this.isLoaded) {
181+
style.visibility = 'initial'
182+
} else {
183+
style.visibility = 'hidden'
171184
}
172185

173186
return <div style={{height:'100%',width:'100%'}}
@@ -177,7 +190,7 @@ export class Pannable extends Etch {
177190
onmousemove={e=>this.ondrag(e)}
178191
onmousewheel={e=>this.zoom(e)}
179192
ondblclick={e=>this.resetAll()}>
180-
<div style={position} className='ink-pannable'>
193+
<div style={style} className='ink-pannable'>
181194
{toView(this.item)}
182195
</div>
183196
</div>;

styles/canopy.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
}
3535

3636
.ink-pannable {
37+
.noshow {
38+
visibility: hidden;
39+
}
3740
img {
3841
pointer-events: none;
3942
}

0 commit comments

Comments
 (0)