From c3964683cdabb6bad1eeb3c4aabe28201218f3a7 Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Sat, 10 Aug 2019 20:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B1=9E=E6=80=A7=E6=8A=98?= =?UTF-8?q?=E5=8F=A0=E5=8A=A8=E7=94=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/editor2/component/ReflectorComponent.jsx | 2 +- .../component/physics/PhysicsTypeComponent.jsx | 2 +- .../src/ui/property/PropertyGroup.jsx | 16 +++++++++++++++- .../src/ui/property/css/PropertyGroup.css | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) 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 {