Skip to content

Instantly share code, notes, and snippets.

@scott-coates
Last active April 20, 2020 13:21
Show Gist options
  • Save scott-coates/f4a006a0c7a7c70ecc98 to your computer and use it in GitHub Desktop.
Save scott-coates/f4a006a0c7a7c70ecc98 to your computer and use it in GitHub Desktop.
A React.js wrapper for the nanoScroller library. https://jamesflorentino.github.io/nanoScrollerJS/.
import ScrollContainer from 'nanoScroller-react.js';
export default React.createClass({
render() {
return (
<nav id="sidebar-wrapper">
<ScrollContainer id="sidebar-scroll-container">
<ul>
Some list of data...
<ul/>
</ScrollContainer>
</nav>
)
}
});
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import nanoScroller from 'nanoscroller';
import $ from 'jquery';
export default React.createClass({
componentDidMount() {
this.scrollContainer = $(ReactDOM.findDOMNode(this.refs['scroll-container']));
this.scrollContainer.nanoScroller();
},
componentWillUnmount() {
this.scrollContainer.nanoScroller({destroy: true});
},
render() {
return (
<div ref="scroll-container" {...this.props} className="nano">
<div className="nano-content">
{this.props.children}
</div>
</div>
)
}
});
@jeanvahe
Copy link

Does this work? I have this: TypeError: this.scrollContainer.nanoScroller is not a function, could you help to check it?

@merksam
Copy link

merksam commented Jun 2, 2016

The same error for me..

@heldr
Copy link

heldr commented Sep 30, 2016

just import jQuery before nanoScroller 🍵

@SevenGuns
Copy link

@heldr Cut that crap 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment