Skip to content

Instantly share code, notes, and snippets.

@RSO
Created September 14, 2014 16:10
Show Gist options
  • Save RSO/042fab27da42cf8cd18e to your computer and use it in GitHub Desktop.
Save RSO/042fab27da42cf8cd18e to your computer and use it in GitHub Desktop.
PerfectScrollComponent React
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