npm.io
2.1.5 • Published 7 years ago

sss-leash

Licence
MIT
Version
2.1.5
Deps
0
Size
15 kB
Vulns
0
Weekly
0

Leash

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.

Keywords