Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pretty-scroll with all npm packages installed. Try it out:

var prettyScroll = require("pretty-scroll")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pretty-scroll v1.1.5


Pretty Scroll

A library to make an element follow you as you scroll



via npm

npm install pretty-scroll --save

or yarn

yarn add pretty-scroll


<div class="js-container">
  <div class="main">
  <div class="sub">
    <div class="js-pretty-scroll">
      <!-- contents here -->
new PrettyScroll('.js-sidebar', {
  container: '.js-container',
  breakpoint: 575, // stop running the js when the window size is smaller than 575px
  offsetTop: 20, // space between the sticky element and the top of the window
  offsetBottom: 20, // space between the sticky element and the bottom of the window
  condition: () => true // you can disable the sticky behavior by returning false, it will be executed when you scroll.
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free