Skip to content

Commit

Permalink
fix(Layout2D): Show/hide slider based on active source
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Feb 27, 2018
1 parent b2e63c0 commit cc4f9fe
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Sources/layouts/Layout2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export default class Layout2D extends React.Component {
constructor(props) {
super(props);

this.state = {
sliceSliderVisible: false,
};

// Setup vtk.js objects
this.activeRepresentation = null;
this.view = props.proxyManager.createProxy('Views', props.viewType);
Expand Down Expand Up @@ -42,11 +46,11 @@ export default class Layout2D extends React.Component {
this.props.proxyManager.onActiveSourceChange(this.onActiveSourceChange),
this.props.proxyManager.onActiveViewChange(this.flush),
];

this.onActiveSourceChange();
}

componentDidMount() {
this.onActiveSourceChange();

this.view.setContainer(this.container);
this.slider.setContainer(this.sliderContainer);

Expand Down Expand Up @@ -121,6 +125,11 @@ export default class Layout2D extends React.Component {
});
}
this.updateSlider();

// update slider visibility based on current active source/representation
this.setState({
sliceSliderVisible: newRep && newRep.getSlice,
});
}

updateSlider() {
Expand Down Expand Up @@ -222,10 +231,7 @@ export default class Layout2D extends React.Component {
className={style.sideBar}
style={{
background: COLOR_BY_AXIS[this.view.getAxis()],
visibility:
this.activeRepresentation && this.activeRepresentation.getSlice
? 'visible'
: 'hidden',
visibility: this.state.sliceSliderVisible ? 'visible' : 'hidden',
}}
ref={(c) => {
this.sliderContainer = c;
Expand Down

0 comments on commit cc4f9fe

Please sign in to comment.