Created
September 14, 2014 16:10
-
-
Save RSO/042fab27da42cf8cd18e to your computer and use it in GitHub Desktop.
PerfectScrollComponent React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.ReactPerfectScrollComponent = React.createClass | |
displayName: 'ReactPerfectScrollComponent' | |
getDefaultProps: -> | |
suppressScrollX: true | |
includePadding: true | |
componentDidMount: -> | |
$(@getDOMNode()).perfectScrollbar | |
suppressScrollX: @props.suppressScrollX | |
includePadding: @props.includePadding | |
# We need to defer this since the size of the elment is not correct yet. | |
_.defer => | |
@updatePerfectScrollbar() | |
updatePerfectScrollbar: -> | |
if @isMounted() | |
$(@getDOMNode()).perfectScrollbar 'update' | |
componentDidUpdate: -> | |
@updatePerfectScrollbar() | |
componentWillUnmount: -> | |
$(@getDOMNode()).perfectScrollbar 'destroy' | |
render: -> | |
React.DOM.div className: @props.className, | |
@props.children |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment