Skip to content

A simple jQuery function that prevents the document from scrolling when the element can no longer scroll such as a modal window

License

Notifications You must be signed in to change notification settings

brockriemenschneider/jquery.scrollfix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JQuery ScrollFix

A simple jQuery function that prevents the document from scrolling when the element can no longer scroll such as a modal window.

Features

  • Prevent's document scrolling when another element is being scrolled.
  • iOS Browsers (Safari, Chrome, etc) start scrolling the container when a element can no longer scroll up or down. This plugin addresses that by counter acting the scrolltop of the document so nothing happens.

How to use

Setup a element that will be scrollable over the document such as a modal window:

<div id="modal" style="overflow: auto;">  
	<p>Hello World</p>  
	...
</div>

Then call the following code on the element:

$("#modal").ScrollFix();  

Options

Optionally you can pass along the following options:

$("#modal").ScrollFix({  
	conditionCallback: function(event, $element) {  
		return $element.is(":visible");  
	}, // the condition to determine if scrolling is enabled/disabled, returning true enables & returning false disables  
	beforeEnabledCallback: function($element) { }, // called before document scrolling has been disabled  
	afterEnabledCallback: function($element) { }, // called after document scrolling has been disabled  
	beforeDisabledCallback: function($element) { }, // called before document scrolling has been re-enabled  
	afterDisabledCallback: function($element) { } // called after document scrolling has been re-enabled  
});

Dependencies

JQuery
attrchange (Included)

License

MIT License

Copyright © 2014 Brock Riemenschneider

About

A simple jQuery function that prevents the document from scrolling when the element can no longer scroll such as a modal window

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published