From 7f254dea7817e68ec0d07f33538d7f967f800a25 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Tue, 19 Sep 2017 15:12:02 -0700 Subject: [PATCH] Replaced react-motion with CSS transition for better perf (#10751) --- www/package.json | 1 - .../StickyResponsiveSidebar.js | 274 +++++++++--------- www/yarn.lock | 10 +- 3 files changed, 135 insertions(+), 150 deletions(-) diff --git a/www/package.json b/www/package.json index 5e235cdc945b0..b6de658213e06 100644 --- a/www/package.json +++ b/www/package.json @@ -27,7 +27,6 @@ "glamor": "^2.20.40", "hex2rgba": "^0.0.1", "react-live": "^1.7.1", - "react-motion": "^0.5.1", "react-sticky": "^6.0.1", "remarkable": "^1.7.1", "slugify": "^1.2.1" diff --git a/www/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js b/www/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js index 8c0f068408fe7..e76d96b99d62f 100644 --- a/www/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js +++ b/www/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js @@ -16,7 +16,6 @@ import {Component, React} from 'react'; import isItemActive from 'utils/isItemActive'; import Sidebar from 'templates/components/Sidebar'; import {colors, media} from 'theme'; -import {Motion, spring} from 'react-motion'; import ChevronSvg from './ChevronSvg'; function findActiveItemTitle(location, defaultActiveSection) { @@ -59,6 +58,7 @@ class StickyResponsiveSidebar extends Component { render() { const {defaultActiveSection, location} = this.props; + const {open} = this.state; const smallScreenSidebarStyles = { top: 0, left: 0, @@ -70,7 +70,7 @@ class StickyResponsiveSidebar extends Component { height: '100vh', overflowY: 'auto', WebkitOverflowScrolling: 'touch', - pointerEvents: this.state.open ? 'auto' : 'none', + pointerEvents: open ? 'auto' : 'none', }; const smallScreenBottomBarStyles = { @@ -81,167 +81,161 @@ class StickyResponsiveSidebar extends Component { ? findActiveItemTitle(location, defaultActiveSection) : null; + const iconOffset = open ? 7 : 0; + const labelOffset = open ? -40 : 0; + const menuOpacity = open ? 1 : 0; + const menuOffset = open ? 0 : 40; + return ( - - {value => ( -
+
+
+
+ +
+
+
+
- + +
-
-
- +
- - + {title}
-
-
- {title} -
-
- Close -
-
+ Close
- +
-
- )} - + +
+
); } } diff --git a/www/yarn.lock b/www/yarn.lock index 941bf3092b8af..cea2b9eb2bb44 100644 --- a/www/yarn.lock +++ b/www/yarn.lock @@ -6963,7 +6963,7 @@ querystringify@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-1.0.0.tgz#6286242112c5b712fa654e526652bf6a13ff05cb" -raf@^3.1.0, raf@^3.3.0: +raf@^3.3.0: version "3.3.2" resolved "https://registry.yarnpkg.com/raf/-/raf-3.3.2.tgz#0c13be0b5b49b46f76d6669248d527cf2b02fe27" dependencies: @@ -7051,14 +7051,6 @@ react-live@^1.7.1: prop-types "^15.5.8" unescape "^0.2.0" -react-motion@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/react-motion/-/react-motion-0.5.1.tgz#b90631408175ab1668e173caccd66d41a44f4592" - dependencies: - performance-now "^0.2.0" - prop-types "^15.5.8" - raf "^3.1.0" - react-proxy@^3.0.0-alpha.0: version "3.0.0-alpha.1" resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-3.0.0-alpha.1.tgz#4400426bcfa80caa6724c7755695315209fa4b07"