diff --git a/ShadowEditor.Web/src/editor2/component/ReflectorComponent.jsx b/ShadowEditor.Web/src/editor2/component/ReflectorComponent.jsx index 22c45f7c..c50489bd 100644 --- a/ShadowEditor.Web/src/editor2/component/ReflectorComponent.jsx +++ b/ShadowEditor.Web/src/editor2/component/ReflectorComponent.jsx @@ -21,7 +21,7 @@ class ReflectorComponent extends React.Component { this.state = { show: false, - expanded: true, + expanded: false, reflect: false, showColor: false, diff --git a/ShadowEditor.Web/src/editor2/component/physics/PhysicsTypeComponent.jsx b/ShadowEditor.Web/src/editor2/component/physics/PhysicsTypeComponent.jsx index c3f5ab3f..6070cd56 100644 --- a/ShadowEditor.Web/src/editor2/component/physics/PhysicsTypeComponent.jsx +++ b/ShadowEditor.Web/src/editor2/component/physics/PhysicsTypeComponent.jsx @@ -17,7 +17,7 @@ class PhysicsTypeComponent extends React.Component { this.state = { show: false, - expanded: true, + expanded: false, physicsEnabled: false, type: 'rigidBody', }; diff --git a/ShadowEditor.Web/src/ui/property/PropertyGroup.jsx b/ShadowEditor.Web/src/ui/property/PropertyGroup.jsx index 3c2915dd..62d783d2 100644 --- a/ShadowEditor.Web/src/ui/property/PropertyGroup.jsx +++ b/ShadowEditor.Web/src/ui/property/PropertyGroup.jsx @@ -10,6 +10,8 @@ class PropertyGroup extends React.Component { constructor(props) { super(props); + this.contentRef = React.createRef(); + this.handleExpand = this.handleExpand.bind(this, props.onExpand); } @@ -23,7 +25,7 @@ class PropertyGroup extends React.Component {
{title}
-
+
{React.Children.map(children, (n, i) => { if (n.props.show === false) { return null; @@ -44,6 +46,18 @@ class PropertyGroup extends React.Component {
; } + componentDidMount() { + let content = this.contentRef.current; + let height = 0; + + for (let i = 0; i < content.children.length; i++) { + let child = content.children[i]; + height += child.offsetHeight; // offsetHeight包含下边框 + } + + content.style.height = `${height}px`; + } + handleExpand(onExpand, event) { const expanded = event.target.getAttribute('expanded') === 'true'; onExpand && onExpand(!expanded, event); diff --git a/ShadowEditor.Web/src/ui/property/css/PropertyGroup.css b/ShadowEditor.Web/src/ui/property/css/PropertyGroup.css index 013ae62e..9d8a23e3 100644 --- a/ShadowEditor.Web/src/ui/property/css/PropertyGroup.css +++ b/ShadowEditor.Web/src/ui/property/css/PropertyGroup.css @@ -57,7 +57,7 @@ } .PropertyGroup>.content.collapsed { - height: 0; + height: 0 !important; } .PropertyGroup>.content>.property {