about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-05-17 07:24:46 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-17 00:24:46 +0200
commit3722f908655b8de7669c89c10aeff10a2c07d277 (patch)
treea4238df047391c812cb01f77649be939e5387ac5 /app/javascript
parent9bddb946f069c9dc933da9b36a8a1d9769ecd898 (diff)
Make .column-collapse animation simple (#3086)
* Always set `overflow: auto` to allow scroll just after opening
* Remove bounce animation which may cause unintended behavior due to max-height
* Use CSS transition instead of react-motion
* Some CSS refactoring including className changing
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/components/column_collapsable.js16
-rw-r--r--app/javascript/styles/components.scss41
2 files changed, 31 insertions, 26 deletions
diff --git a/app/javascript/mastodon/components/column_collapsable.js b/app/javascript/mastodon/components/column_collapsable.js
index 3154c977f..a54f76932 100644
--- a/app/javascript/mastodon/components/column_collapsable.js
+++ b/app/javascript/mastodon/components/column_collapsable.js
@@ -1,5 +1,4 @@
 import React from 'react';
-import { Motion, spring } from 'react-motion';
 import PropTypes from 'prop-types';
 
 class ColumnCollapsable extends React.PureComponent {
@@ -29,21 +28,16 @@ class ColumnCollapsable extends React.PureComponent {
   render () {
     const { icon, title, fullHeight, children } = this.props;
     const { collapsed } = this.state;
-    const collapsedClassName = collapsed ? 'collapsable-collapsed' : 'collapsable';
 
     return (
-      <div className='column-collapsable'>
-        <div role='button' tabIndex='0' title={`${title}`} className={`column-icon ${collapsedClassName}`} onClick={this.handleToggleCollapsed}>
+      <div className={`column-collapsable ${collapsed ? 'collapsed' : ''}`}>
+        <div role='button' tabIndex='0' title={`${title}`} className='column-collapsable__button column-icon' onClick={this.handleToggleCollapsed}>
           <i className={`fa fa-${icon}`} />
         </div>
 
-        <Motion defaultStyle={{ opacity: 0, height: 0 }} style={{ opacity: spring(collapsed ? 0 : 100), height: spring(collapsed ? 0 : fullHeight, collapsed ? undefined : { stiffness: 150, damping: 9 }) }}>
-          {({ opacity, height }) =>
-            <div style={{ overflow: height === fullHeight ? 'auto' : 'hidden', height: `${height}px`, opacity: opacity / 100, maxHeight: '70vh' }}>
-              {children}
-            </div>
-          }
-        </Motion>
+        <div className='column-collapsable__content' style={{ height: `${fullHeight}px`, maxHeight: '70vh' }}>
+          {children}
+        </div>
       </div>
     );
   }
diff --git a/app/javascript/styles/components.scss b/app/javascript/styles/components.scss
index 4de8b7969..3c90ae728 100644
--- a/app/javascript/styles/components.scss
+++ b/app/javascript/styles/components.scss
@@ -48,6 +48,32 @@
 
 .column-collapsable {
   position: relative;
+
+  .column-collapsable__content {
+    overflow: auto;
+    transition: 300ms ease;
+    opacity: 1;
+  }
+
+  &.collapsed .column-collapsable__content {
+    height: 0 !important;
+    opacity: 0;
+  }
+
+  .column-collapsable__button {
+    color: $primary-text-color;
+    background: lighten($ui-base-color, 8%);
+
+    &:hover {
+      color: $primary-text-color;
+      background: lighten($ui-base-color, 8%);
+    }
+  }
+
+  &.collapsed .column-collapsable__button {
+    color: $ui-primary-color;
+    background: lighten($ui-base-color, 4%);
+  }
 }
 
 .column-icon {
@@ -1984,21 +2010,6 @@ button.icon-button.active i.fa-retweet {
   text-align: center;
 }
 
-.collapsable-collapsed {
-  color: $ui-primary-color;
-  background: lighten($ui-base-color, 4%);
-}
-
-.collapsable {
-  color: $primary-text-color;
-  background: lighten($ui-base-color, 8%);
-
-  &:hover {
-    color: $primary-text-color;
-    background: lighten($ui-base-color, 8%);
-  }
-}
-
 .video-error-cover {
   align-items: center;
   background: $base-overlay-background;