Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

Latest commit

 

History

History
46 lines (31 loc) · 919 Bytes

README.md

File metadata and controls

46 lines (31 loc) · 919 Bytes

react-scroll-into-view-mixin

A ReactJS mixin that enables components to scroll HTML elements into view.

Install

npm install react-scroll-into-view-mixin --save

Example

var ScrollIntoViewMixin = require('react-scroll-into-view-mixin');

function getSelected() {
    return this.getDOMNode().querySelector('.is-selected');
}

function shouldScrollUp(el, prevProps, prevState) {
    return this.props.selectedIndex < prevProps.selectedIndex;
}

function shouldScrollDown(el, prevProps, prevState) {
    return this.props.selectedIndex > prevProps.selectedIndex;
}

module.exports = React.createClass({
    mixins: [
        ScrollIntoViewMixin(getSelected, shouldScrollUp, shouldScrollDown)
    ]
}

Contributing

Contributions of any sort are welcome.

License

MIT.