Skip to content

Commit 18ab40c

Browse files
committed
Heights & transitioning
1 parent ceb0433 commit 18ab40c

8 files changed

+54
-46
lines changed

dist/react-workflow-viz.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-workflow-viz.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-workflow-viz.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-workflow-viz.node.js

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21554,7 +21554,7 @@ var ScrollContainer_ScrollContainer = function (_React$PureComponent) {
2155421554
_this = ScrollContainer_possibleConstructorReturn(this, ScrollContainer_getPrototypeOf(ScrollContainer).call(this, props));
2155521555
_this.state = {
2155621556
'mounted': false,
21557-
'isHeightDecreasing': false,
21557+
'isHeightDecreasing': null,
2155821558
'outerHeight': props.outerHeight,
2155921559
'pastHeight': null
2156021560
};
@@ -21577,34 +21577,21 @@ var ScrollContainer_ScrollContainer = function (_React$PureComponent) {
2157721577

2157821578
var updateOuterHeight = this.props.outerHeight;
2157921579

21580-
if (updateOuterHeight < prevProps.outerHeight) {
21581-
this.setState(function (_ref) {
21582-
_ref.isHeightDecreasing;
21583-
return {
21584-
'isHeightDecreasing': true,
21585-
'pastHeight': prevProps.outerHeight,
21586-
outerHeight: updateOuterHeight
21587-
};
21580+
if (updateOuterHeight !== prevProps.outerHeight) {
21581+
var isHeightDecreasing = updateOuterHeight < prevProps.outerHeight;
21582+
this.setState({
21583+
'isHeightDecreasing': isHeightDecreasing,
21584+
'pastHeight': isHeightDecreasing ? prevProps.outerHeight : null,
21585+
'outerHeight': updateOuterHeight
2158821586
}, function () {
2158921587
_this2.heightTimer && clearTimeout(_this2.heightTimer);
2159021588
_this2.heightTimer = setTimeout(function () {
2159121589
_this2.setState({
21592-
'isHeightDecreasing': false,
21593-
'pastHeight': null,
21594-
outerHeight: updateOuterHeight
21590+
'isHeightDecreasing': null,
21591+
'pastHeight': null
2159521592
});
2159621593
}, 500);
2159721594
});
21598-
return;
21599-
}
21600-
21601-
if (updateOuterHeight > prevProps.outerHeight) {
21602-
this.heightTimer && clearTimeout(this.heightTimer);
21603-
this.setState({
21604-
'isHeightDecreasing': false,
21605-
'pastHeight': null,
21606-
outerHeight: updateOuterHeight
21607-
});
2160821595
}
2160921596
}
2161021597
}, {
@@ -21624,12 +21611,17 @@ var ScrollContainer_ScrollContainer = function (_React$PureComponent) {
2162421611
pastHeight = _this$state.pastHeight,
2162521612
isHeightDecreasing = _this$state.isHeightDecreasing,
2162621613
mounted = _this$state.mounted;
21627-
var innerCls = 'scroll-container' + (isHeightDecreasing ? ' height-decreasing' : '');
21614+
var innerCls = 'scroll-container' + (isHeightDecreasing ? ' height-decreasing' : '') + (isHeightDecreasing === false ? ' height-increasing' : '');
2162821615
var innerStyle = {
2162921616
'width': Math.max(contentWidth, width),
2163021617
'height': outerHeight,
2163121618
'overflowY': outerHeight < minHeight ? "hidden" : null
2163221619
};
21620+
21621+
if (minHeight > outerHeight) {
21622+
innerStyle.paddingTop = innerStyle.paddingBottom = Math.floor((minHeight - outerHeight) / 2);
21623+
}
21624+
2163321625
return external_commonjs_react_commonjs2_react_amd_react_root_React_default.a.createElement("div", {
2163421626
className: "scroll-container-wrapper",
2163521627
ref: this.containerRef,

dist/react-workflow-viz.node.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hms-dbmi-bgm/react-workflow-viz",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "React component for visualizing CWL-like workflows and provenance graphs.",
55
"main": "dist/react-workflow-viz.min.js",
66
"module": "dist/react-workflow-viz.node.js",

src/components/ScrollContainer.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class ScrollContainer extends React.PureComponent {
1111
super(props);
1212
this.state = {
1313
'mounted' : false,
14-
'isHeightDecreasing' : false,
14+
'isHeightDecreasing' : null,
1515
'outerHeight' : props.outerHeight,
1616
'pastHeight' : null
1717
};
@@ -25,35 +25,39 @@ export default class ScrollContainer extends React.PureComponent {
2525

2626
componentDidUpdate(prevProps, pastState){
2727
const { outerHeight: updateOuterHeight } = this.props;
28-
if (updateOuterHeight < prevProps.outerHeight){
29-
this.setState(({ isHeightDecreasing })=>{
30-
return { 'isHeightDecreasing' : true, 'pastHeight' : prevProps.outerHeight, outerHeight: updateOuterHeight };
28+
if (updateOuterHeight !== prevProps.outerHeight){
29+
const isHeightDecreasing = updateOuterHeight < prevProps.outerHeight;
30+
this.setState({
31+
'isHeightDecreasing' : isHeightDecreasing,
32+
'pastHeight' : isHeightDecreasing ? prevProps.outerHeight : null,
33+
'outerHeight': updateOuterHeight
3134
}, ()=>{
3235
this.heightTimer && clearTimeout(this.heightTimer);
3336
this.heightTimer = setTimeout(()=>{
34-
this.setState({ 'isHeightDecreasing' : false, 'pastHeight' : null, outerHeight: updateOuterHeight });
37+
this.setState({ 'isHeightDecreasing' : null, 'pastHeight' : null });
3538
}, 500);
3639
});
37-
return;
38-
}
39-
40-
if (updateOuterHeight > prevProps.outerHeight){
41-
this.heightTimer && clearTimeout(this.heightTimer);
42-
this.setState({ 'isHeightDecreasing' : false, 'pastHeight' : null, outerHeight: updateOuterHeight });
43-
return;
4440
}
4541
}
4642

4743
render(){
4844
const { innerMargin, innerWidth, children, contentWidth, width, minHeight } = this.props;
4945
const { outerHeight, pastHeight, isHeightDecreasing, mounted } = this.state;
50-
const innerCls = 'scroll-container' + (isHeightDecreasing ? ' height-decreasing' : '');
46+
const innerCls = (
47+
'scroll-container'
48+
+ (isHeightDecreasing ? ' height-decreasing' : '')
49+
+ (isHeightDecreasing === false ? ' height-increasing' : '')
50+
);
5151
const innerStyle = {
5252
'width' : Math.max(contentWidth, width),
5353
'height': outerHeight,
5454
'overflowY' : outerHeight < minHeight ? "hidden" : null
5555
};
5656

57+
if (minHeight > outerHeight){
58+
innerStyle.paddingTop = innerStyle.paddingBottom = Math.floor((minHeight - outerHeight) / 2);
59+
}
60+
5761
return (
5862
<div className="scroll-container-wrapper" ref={this.containerRef} style={{ width, minHeight }}>
5963
<div className={innerCls} style={innerStyle}>

src/styles.scss

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,24 +528,36 @@ $workflow-node-color-type-global-context: #ffb3b3 !default;
528528

529529
display: flex;
530530
justify-content: center;
531-
align-items: center;
531+
//align-items: center;
532532

533533
}
534534

535535
.scroll-container {
536536

537537
position: relative;
538-
transition: height .5s ease-out, width .5s ease-out;
538+
box-sizing: content-box;
539+
transition:
540+
height .5s ease-out,
541+
width 0s .5s ease-out,
542+
padding-top .5s ease-out,
543+
padding-bottom .5s ease-out;
539544

540545
&.height-decreasing {
541-
transition: height .5s .5s ease-out, width .5s ease-out;
546+
transition:
547+
height .5s ease-out,
548+
width 0s .5s ease-out,
549+
padding-top .5s ease-out,
550+
padding-bottom .5s ease-out;
551+
}
552+
553+
&.height-decreasing,
554+
&.height-increasing {
555+
overflow: hidden;
542556
}
543557

544558
.nodes-layer-wrapper,
545559
.edges-layer-wrapper {
546560
position: absolute;
547-
left: 0;
548-
top: 0;
549561
}
550562

551563
.nodes-layer-wrapper {

0 commit comments

Comments
 (0)