@jbrowse/plugin-linear-genome-view
Version:
JBrowse 2 linear genome view
33 lines (32 loc) • 1.05 kB
JavaScript
import { getConf } from '@jbrowse/core/configuration';
import { types } from '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() {
var _a;
return (_a = self.heightPreConfig) !== null && _a !== void 0 ? _a : 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;
},
}));
}