about summary refs log tree commit diff
path: root/app/javascript/mastodon/components/icon_button.js
diff options
context:
space:
mode:
authorNolan Lawson <nolan@nolanlawson.com>2017-10-27 10:08:07 -0700
committerEugen Rochko <eugen@zeonfederated.com>2017-10-27 19:08:07 +0200
commite843f62f479d9b8b2d177e587c3e10b5e3945f68 (patch)
tree7b446242712e1fdb81e986f03e24d07969dd6687 /app/javascript/mastodon/components/icon_button.js
parentec487166db4d9d532e6090c76b65c797780fa841 (diff)
Avoid unnecessary Motion components in icon_button.js (#5544)
Diffstat (limited to 'app/javascript/mastodon/components/icon_button.js')
-rw-r--r--app/javascript/mastodon/components/icon_button.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js
index d8e445cef..06f53841d 100644
--- a/app/javascript/mastodon/components/icon_button.js
+++ b/app/javascript/mastodon/components/icon_button.js
@@ -72,6 +72,25 @@ export default class IconButton extends React.PureComponent {
       overlayed: overlay,
     });
 
+    if (!animate) {
+      // Perf optimization: avoid unnecessary <Motion> components unless
+      // we actually need to animate.
+      return (
+        <button
+          aria-label={title}
+          aria-pressed={pressed}
+          aria-expanded={expanded}
+          title={title}
+          className={classes}
+          onClick={this.handleClick}
+          style={style}
+          tabIndex={tabIndex}
+        >
+          <i className={`fa fa-fw fa-${icon}`} aria-hidden='true' />
+        </button>
+      );
+    }
+
     return (
       <Motion defaultStyle={{ rotate: active ? -360 : 0 }} style={{ rotate: animate ? spring(active ? -360 : 0, { stiffness: 120, damping: 7 }) : 0 }}>
         {({ rotate }) =>