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

andornaut/react-scroll-into-view-mixin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published