diff --git a/src/component/Upload/Fab.js b/src/component/Upload/Fab.js index 729f740..b5815cb 100644 --- a/src/component/Upload/Fab.js +++ b/src/component/Upload/Fab.js @@ -7,6 +7,7 @@ import CreateNewFolderIcon from "@material-ui/icons/CreateNewFolder"; import PublishIcon from "@material-ui/icons/Publish"; import { toggleSnackbar } from "../../actions/index"; import { useDispatch } from "react-redux"; +import Zoom from '@material-ui/core/Zoom'; const useStyles = makeStyles(theme => ({ fab: { @@ -42,6 +43,32 @@ export default function UploadButton(props) { [dispatch] ); + let prev = window.scrollY; + let lastUpdate = window.scrollY; + const show = 50; + + useEffect(() => { + window.addEventListener('scroll', e => handleNavigation(e)); + }, []) + + const handleNavigation = (e) => { + const window = e.currentTarget; + + if (prev > window.scrollY) { + if (lastUpdate - window.scrollY > show){ + lastUpdate = window.scrollY; + setHidden(false); + } + } else if (prev < window.scrollY) { + if (window.scrollY - lastUpdate > show){ + lastUpdate = window.scrollY; + setHidden(true); + } + } + prev = window.scrollY; + }; + + useEffect(() => { setQueued(props.Queued); }, [props.Queued]); @@ -76,6 +103,7 @@ export default function UploadButton(props) { }; return ( + + ); } diff --git a/src/component/Uploader.js b/src/component/Uploader.js index d9c78a8..35592bd 100644 --- a/src/component/Uploader.js +++ b/src/component/Uploader.js @@ -111,23 +111,6 @@ class UploaderCompoment extends Component { } } - componentDidMount() { - this.prev = window.scrollY; - window.addEventListener('scroll', e => this.handleNavigation(e)); - - } - - handleNavigation = (e) => { - const window = e.currentTarget; - - if (this.prev > window.scrollY) { - console.log("scrolling up"); - } else if (this.prev < window.scrollY) { - console.log("scrolling down"); - } - this.prev = window.scrollY; - }; - onError() {} openFileList = () => {