Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryandrewjohnson/jquery-scrollfreeze
A simple jQuery plugin that allows you to easily disable(freeze) user scroll events on the window.
https://github.com/ryandrewjohnson/jquery-scrollfreeze
Last synced: 9 days ago
JSON representation
A simple jQuery plugin that allows you to easily disable(freeze) user scroll events on the window.
- Host: GitHub
- URL: https://github.com/ryandrewjohnson/jquery-scrollfreeze
- Owner: ryandrewjohnson
- License: mit
- Created: 2014-04-08T17:54:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-30T20:02:08.000Z (over 10 years ago)
- Last Synced: 2024-04-15T01:18:00.242Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 191 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jquery.scrollfreeze
A simple jQuery plugin that allows you to easily disable(freeze) user scroll events on the window.
## Installation
Include script *after* the jQuery library:
```html
```
The plugin can also be loaded as an AMD module.
## Usage
The plugin automatically initializes on document.ready, and requires no configuration except for one optional setting `useOverflow`, which I will explain shortly.
To disable(freeze) user scroll:
```javascript
$.scrollFreeze.freeze();
```To renable(thaw) user scroll:
```javascript
$.scrollFreeze.thaw();
```To toggle between disabled and enabled scroll:
```javascript
$.scrollFreeze.toggle();
```By default `freeze` and `thaw` will only block user scroll events e.g. Mouse Wheel, arrow keys. The user still has the ability to use the scroll bar to scroll the page by default. To prevent this call the `useOverflow` method upon page load.
```javascript
$.scrollFreeze.useOverflow();
```To disable plugin, which essentially removes the event listenrs on the plugin:
```javascript
$.scrollFreeze.disable();
```If you need to re-enable after disabling:
```javascript
$.scrollFreeze.enable();
```Some convenience methods to retrieve state:
```javascript
$.scrollFreeze.isFrozen();
$.scrollFreeze.isEnabled();
```## Examples
See the demo included for a simple example.
## Notes
* This was never intended for mobile use and therefore was never tested on mobile devices. Although it may work on mobile if `useOverflow` has been set.
* This script was created out of necessity when I was working on a single page application that automatically scrolled between sections. I needed to prevent the user's scroll events from interfering with the automated scrolling.## Author
[Ryan Johnson](https://github.com/ryandrewjohnson)