UNPKG

@krowdy-ui/core

Version:

React components that implement Google's Material Design.

32 lines (30 loc) 1.08 kB
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["direction"]; import React from 'react'; import Slide from '../Slide'; import useScrollTrigger from '../useScrollTrigger'; var AlterDirection = { down: 'up', left: 'right', right: 'left', up: 'down' }; var HideOnScroll = React.forwardRef(function (_ref, ref) { var _ref$direction = _ref.direction, direction = _ref$direction === void 0 ? 'down' : _ref$direction, props = _objectWithoutProperties(_ref, _excluded); var children = props.children, window = props.window; // Note that you normally won't need to set the window ref as useScrollTrigger // will default to window. // This is only being set here because the demo is in an iframe. var trigger = useScrollTrigger({ target: window ? window() : undefined }); return /*#__PURE__*/React.createElement(Slide, { appear: false, direction: direction ? AlterDirection[direction] : undefined, "in": !trigger, ref: ref }, children); }); export default HideOnScroll;