react-classpoint v1.0.1
react-classpoint
A React component that has the ability to change classNames or styles when in view and go back when it goes out of the view.
Installation
NPM: npm install --save react-classpoint
Yarn: yarn add react-classpoint
Usage
import React, { Component } from 'react'
import { render } from 'react-dom'
import ClassPoint from 'react-classpoint'
class App extends Component {
render() {
return (
<ClassPoint
activeClass="is-active"
horizontal={false}
topOffset={0}
bottomOffset={0}
activeStyle={{ color: '#ffffff' }}
>
<h1>Hello World</h1>
</ClassPoint>
)
}
}
render(<App />, document.getElementById('root'))
Now whenever the h1 element becomes in view, the class of is-active will be applied to it.
Options
Since react-classpoint is dependent on react-waypoint, there are a couple of options that you can customize for your own needs:
horizontal: Boolean (Whether the checking should be horizontal instead of vertical or not)
topOffset: Number/String
bottomOffset: Number/String
activeClass: String (The class or classes to add when in view)
activeStyle: Object (A styling to add when the element is in view)
License
MIT License
Copyright (c) 2017 Ahmed Tarek
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.