All Projects → appleple → Pretty Scroll

appleple / Pretty Scroll

Licence: mit
A modern JS library to make an element follow you as you scroll

Programming Languages

javascript
184084 projects - #8 most used programming language

Pretty Scroll

A library to make an element follow you as you scroll

Demos

Installation

via npm

npm install pretty-scroll --save

or yarn

yarn add pretty-scroll

Basic

<div class="js-container">
  <div class="main">
  </div>
  <div class="sub">
    <div class="js-sidebar">
      <!-- contents here -->
    </div>
  </div>
</div>
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.
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].