STYLE SWITCHER

Prevent scrolling of parent element – Jquery

Please ensure that you are include jquery.mousewheel.js
<!DOCTYPE html> 
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>

<style>
 * { padding: 0; margin: 0; }
 html { min-height: 1000%; }

 #toolbox {
 overflow: auto;
 position: fixed;
 top: 100px;
 left: 200px;
 width: 200px;
 height: 300px;
 background: #ccc;
 }
</style>

</head>
<body>

 <div id="toolbox">
 <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
 </div>

 <script src="https://rawgit.com/jquery/jquery-mousewheel/master/jquery.mousewheel.js"></script>

</body>
</html>

$(function() {

 var toolbox = $('#toolbox'),
 height = toolbox.height(),
 scrollHeight = toolbox.get(0).scrollHeight;

 toolbox.bind('mousewheel', function(e, d) {
 if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
 e.preventDefault();
 }
 });

});
Example

Another example

$('div').on( 'mousewheel DOMMouseScroll', function (e) {

var e0 = e.originalEvent;
var delta = e0.wheelDelta || -e0.detail;

this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();
});
Website

Recent Article

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  1. Spirit is the debut album by rock band Spirit, released on January 22, 1968.Terry Kath – Died 1-23-78 – Accidental self inflicted gun shot Rock Born 1-31-1946 in Chicago, Illinois, U.Eine absurde Paarung, der frГјhpensionierte Pop-Tycoon und die abscheulichen Ramones.Se vocГЄ me disser que me ama eu nГЈo vou acreditar VocГЄ me diz que me quer e nГЈo pode ser fiel VocГЄ deixou dirigindo sozinho e triste,mulher Confesso, se vocГЄ quer saber, se vocГЄ quer saber.Rob was great and my son loved Kevin. https://sweralagunwaihag.deimakbecetaldapheholtairroprinmiss.co Click Choose what to clear underneath Clear browsing data.And you may ask yourself, How did they get here.Enotris Johnson, ComposerLyricist – Richard Penniman, ComposerLyricist – Little Richard, MainArtist Copyright 2017 Craft Recordings, a division of Concord Music Group, Inc.By kevin, October 4, 2018.Born and raised by Spanish parents on the outskirts of Paris in the 60s, Chao s earliest musical influences came from Latin artists including Bola de Nieve.

  2. Hey all! Recently I have been fighting with a lot of personal issues. Friends and doctors keep telling me I should consider taking meds, so I may as well read more and see how it goes. Problem is, I haven’t taken it for a while, and don’t wanna get back to it, we’ll see how it goes.

  3. Just want to say your article is as amazing. The clearness in your post is just nice and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please keep up the enjoyable work.

  • Keep your skills sharp, get informed.

    Subscribe to our mailing list and get interesting stuff and updates to your email inbox