UNPKG

@6thquake/react-material

Version:

React components that implement Google's Material Design.

63 lines (56 loc) 1.26 kB
import React from 'react'; import PropTypes from 'prop-types'; import withStyles from '../styles/withStyles'; export const styles = theme => ({ root: { position: 'sticky' } }); class Affix extends React.Component { render() { const { classes, offsetBottom, offsetTop, offsetLeft, offsetRight } = this.props; const style = { top: offsetTop, left: offsetLeft, right: offsetRight, bottom: offsetBottom }; return React.createElement("div", { style: style, className: classes.root }, this.props.children); } } process.env.NODE_ENV !== "production" ? Affix.propTypes = { /** * Override or extend the styles applied to the component. * See [CSS API](#css-api) below for more details. */ classes: PropTypes.object, /** * fixed at {offsetBottom} from bottom */ offsetBottom: PropTypes.number, /** * fixed at {offsetLeft} from left */ offsetLeft: PropTypes.number, /** * fixed at {offsetRight} from right */ offsetRight: PropTypes.number, /** * fixed at {offsetTop} from top */ offsetTop: PropTypes.number } : void 0; Affix.defaultProps = {}; export default withStyles(styles, { name: 'RMAffix' })(Affix);