react-scroll#Events JavaScript Examples

The following examples show how to use react-scroll#Events. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Menu.js    From circles-website with GNU Affero General Public License v3.0 5 votes vote down vote up
MainMenu = ({ t, large, fixed, ...otherProps }) => {
  const [open, setOpen] = useState(false);

  Events.scrollEvent.register('begin', function (to, element) {
    setOpen(false);
  });

  if (large) {
    return (
      <nav>
        <MenuContent large />
      </nav>
    );
  }

  const onOpen = () => setOpen(true);
  const onClose = () => setOpen(false);

  return (
    <nav>
      <Box width="100%" align="center" {...otherProps}>
        {open && (
          <Layer
            position="right"
            full="vertical"
            onClickOutside={onClose}
            onEsc={onClose}
            responsive={false}
          >
            <Box pad="small" justify="around" height="100vh">
              {fixed ? (
                <div />
              ) : (
                <Button
                  alignSelf="end"
                  onClick={onClose}
                  icon={<CloseIcon color="brand4" />}
                />
              )}
              <Box pad={{ top: 'medium' }}>
                <MenuContent t={t} large={false} />
              </Box>
              <Box>
                <Box justify="center" direction="row">
                  <SocialMenu
                    fixed={fixed}
                    mobileMenu={!large}
                    margin={{ top: 'medium' }}
                  />
                </Box>
              </Box>
            </Box>
          </Layer>
        )}
        <Button
          alignSelf="end"
          onClick={open ? onClose : onOpen}
          icon={open ? <CloseIcon color="white" /> : <MenuIcon color="white" />}
          margin={{ right: 'medium' }}
        />
      </Box>
    </nav>
  );
}