Skip to content

Momentum-Scrolling Javascript Library

Notifications You must be signed in to change notification settings

FredericRezeau/butter.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Butter.js

"Smooth like Buttah"

Momentum Scrolling Javascript Library

Written by: BCJ Development

Demo

https://bcjdevelopment.github.io/butter.js/

About

This javascript library is largely based on the "Luxy.js" library written by Mineo Okuda: https://github.com/min30327/luxy.js

This library is meant to be a lightweight momentum scrolling library. Because of this, it does not currently support individual parallax elements (support for this may be included in a similar library soon).

How to Use It

Include a script link to butter.js:

<script src="butter.js"></script>

Create a content wrapper with an id of "butter" (keep fixed html elements outside of content wrapper):

<div id="butter">
  Put web page content here...
</div>

Initialize butter.js and enjoy:

<script>
  // smooth like buttah...
  butter.init();
</script>

Call butter.cancel() to restore page to default settings:

<script>
  // cancel momentum scrolling
  butter.cancel()
</script>

Options

Option default description
wrapperId 'butter' The id of the content wrapper
wrapperDamper 0.07 Changes speed of scroll (increase to speed scroll up)
cancelOnTouch false If true, calls butter.cancel() when touch event occurs

NOTE: It is recommended to set cancelOnTouch to true to avoid scrolljacking on mobile devices since they intrinsically support momentum scrolling.

<script>
  // set options when initializing butter.js
  var options = {
    wrapperId: 'customDefaultId',
    wrapperDamper: 0.10,
    cancelOnTouch: true
  };
  butter.init(options);
</script>

License

Free and Open Source under the MIT License.

About

Momentum-Scrolling Javascript Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.2%
  • HTML 26.8%