2.1.5 • Published 5 years ago

sss-leash v2.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

About

Leash is a Browser scrollbar helper (Disable/Enable by X and Y).

Installation

1) Download Leash

2) Connect Leash before your scripts.

3) See how to create the Leash.

<script src="/assets/js/lib/Leash.js"></script>
Package managers 😎

If you are using package managers such as npm or yarn, import this lib as usual.

# Yarn
yarn add sss-leash

# NPM
npm i sss-leash --save

Do import Leash from 'sss-leash';

Init

Create new Leash

const body = document.body;
const ScrollLeash = new Leash(body);

Methods

Lock

Lock scroll X or Y

ScrollLeash.lockX();
ScrollLeash.lockY();

If you are facing jumps in position:fixed elements, add [data-scroll-fixed] attribute to this element

Release

Release scroll X or Y

ScrollLeash.releaseX();
ScrollLeash.releaseY();

isScrollable

Checks isScrollbar and isScrollAvailable

const isScrollable = Leash.isScrollable(document.documentElement); // true

isScrollBar

Checks scrollBar existence;

const isScrollBar = Leash.isScrollBar(document.documentElement); // true

isScrollAvailable

Checks if container can be scrolled

const isScrollAvailable = Leash.isScrollAvailable(document.documentElement); // true

License

This project is available under the MIT license.