@jbrowse/plugin-linear-genome-view
Version:
JBrowse 2 linear genome view
32 lines (31 loc) • 1.01 kB
JavaScript
import { getConf } from '@jbrowse/core/configuration';
import { types } from '@jbrowse/mobx-state-tree';
const minDisplayHeight = 20;
export default function TrackHeightMixin() {
return types
.model({
heightPreConfig: types.maybe(types.refinement('displayHeight', types.number, n => n >= minDisplayHeight)),
})
.volatile(() => ({
scrollTop: 0,
}))
.views(self => ({
get height() {
return self.heightPreConfig ?? getConf(self, 'height');
},
}))
.actions(self => ({
setScrollTop(scrollTop) {
self.scrollTop = scrollTop;
},
setHeight(displayHeight) {
self.heightPreConfig = Math.max(displayHeight, minDisplayHeight);
return self.height;
},
resizeHeight(distance) {
const oldHeight = self.height;
const newHeight = this.setHeight(self.height + distance);
return newHeight - oldHeight;
},
}));
}