Interactive interface for browsing global, full-resolution satellite imagery
remove simplebar (non-react) and fix various scrollbar alignment issues
Jason Kentcf313f6d415b
diff --git a/package-lock.json b/package-lock.jsonindex a02a95927..54330b270 100644--- a/package-lock.json+++ b/package-lock.json@@ -16456,6 +16456,15 @@}}},+ "simplebar-react": {+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/simplebar-react/-/simplebar-react-2.0.4.tgz",+ "integrity": "sha512-8WObHF4VHIVos0A+5jAZGDdUG8OKvBhV5MoflOoF5xxWY9zhrTvynrQM1iDU1cL378urQh41njDPt2D4XGKI/Q==",+ "requires": {+ "prop-types": "^15.6.1",+ "simplebar": "^5.0.3"+ }+ },"sisteransi": {"version": "1.0.3","resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.3.tgz",diff --git a/package.json b/package.jsonindex 0e76a373b..31466ac4b 100644--- a/package.json+++ b/package.json@@ -189,7 +189,7 @@"redux": "^4.0.4","redux-responsive": "^4.3.8","redux-thunk": "^2.3.0",- "simplebar": "5.0.3",+ "simplebar-react": "^2.0.4","supercluster": "3.0.2","web-streams-polyfill": "^1.3.2","whatwg-fetch": "^3.0.0"diff --git a/web/css/layers.css b/web/css/layers.cssindex 7fe0e0b78..e110a00ee 100644--- a/web/css/layers.css+++ b/web/css/layers.css@@ -517,6 +517,7 @@bottom: auto;border-radius: 6px;position: absolute;+ width: 500px;}.layer-settings-modal .modal-title {diff --git a/web/css/scrollbar.css b/web/css/scrollbar.cssindex ee051b88b..b3921a27a 100644--- a/web/css/scrollbar.css+++ b/web/css/scrollbar.css@@ -1,14 +1,11 @@-/***************** simple-scrollbar customizations ***********************/+.simplebar-scrollbar {+ right: 0;+ width: 9px;+}+.simplebar-track .simplebar-scrollbar::before {background-color: #999;border-radius: 0;- width: 9px;-}-.scrollbar-hidden .simplebar-scrollbar {- display: none;-}-.scrollbar-visible .simplebar-track .simplebar-scrollbar::before {opacity: 0.8;- border-radius: 0;}diff --git a/web/js/components/util/scrollbar.js b/web/js/components/util/scrollbar.jsindex fa444bbf6..14403cdf4 100644--- a/web/js/components/util/scrollbar.js+++ b/web/js/components/util/scrollbar.js@@ -1,64 +1,51 @@-import React from 'react';+import React, { useRef, useLayoutEffect } from 'react';import PropTypes from 'prop-types';-import ScrollBar from 'simplebar';-export default class SimpleBar extends React.Component {- constructor(props) {- super(props);- this.state = {- needsScrollBar: false- };- }+import SimpleBarReact from 'simplebar-react';- componentDidMount() {- const element = this.caseEl;- this.scrollBar = new ScrollBar(element);- this.content = this.scrollBar.getScrollElement();- }+export default function Scrollbars(props) {+ const ref = useRef();+ let scrollbarVisible;- componentDidUpdate() {- this.updateBoolean();- // scroll to vertical axis point - note: 0 would be no scroll- const verticalTop = Math.floor(this.props.scrollBarVerticalTop);- if (verticalTop !== 0) {- this.content.scrollTop = verticalTop;+ useLayoutEffect(() => {+ if (!ref || !ref.current) {+ return;}- }+ // if (ref.current.recalculate) {+ // // TODO do we need to recalculate??+ // ref.current.recalculate();+ // }- /**- * Use offsetHeight to determine if scrollbar should be visible- * https://stackoverflow.com/a/42026562/4589331- */- updateBoolean() {- const element = this.content;- const hasOverflowingChildren = element.offsetHeight + 1 < element.scrollHeight;- if (this.state.needsScrollBar !== hasOverflowingChildren) {- this.setState({ needsScrollBar: hasOverflowingChildren });+ const { contentEl, contentWrapperEl } = ref.current;+ if (contentEl) {+ const verticalTop = Math.floor(props.scrollBarVerticalTop);+ scrollbarVisible = contentEl.offsetHeight > contentWrapperEl.offsetHeight;+ contentWrapperEl.scrollTop = verticalTop !== 0 ? verticalTop : 0;++ if (scrollbarVisible) {+ contentEl.classList.add('scrollbar-visible');+ } else {+ contentEl.classList.remove('scrollbar-visible');+ }}- }+ });- render() {- return (- <div- style={this.props.style}- ref={el => {- this.caseEl = el;- }}- className={- this.state.needsScrollBar ? 'scrollbar-visible' : 'scrollbar-hidden'- }- >- {this.props.children}- </div>- );- }+ return (+ <SimpleBarReact+ autoHide={false}+ style={props.style}+ ref={ref}+ >+ {props.children}+ </SimpleBarReact>+ );}-SimpleBar.propTypes = {+Scrollbars.propTypes = {children: PropTypes.node,scrollBarVerticalTop: PropTypes.number,style: PropTypes.object};-SimpleBar.defaultProps = {+Scrollbars.defaultProps = {scrollBarVerticalTop: 0};diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.jsindex 01539a7b6..c6fb6a734 100644--- a/web/js/containers/sidebar/layer.js+++ b/web/js/containers/sidebar/layer.js@@ -370,6 +370,7 @@ const mapDispatchToProps = dispatch => ({wrapClassName: 'clickable-behind-modal',modalClassName: ' layer-info-settings-modal layer-info-modal',timeout: 150,+ size: 'lg',bodyComponentProps: {layer: layer}