0

I tried to prevent parent scrolling with mousewheel in Latest Google Chrome but it doesn't work. So I need some explanation with the code.

$(function() {


var toolbox = $('#68').find('.medium-folder-body'),

//The medium-folder-body height - 500px here
height = toolbox.height(),

//scrollHeight 693px (I got the height but don't understand what is that for)
//what is .get(0) ?
scrollHeight = toolbox.get(0).scrollHeight;

toolbox.bind('mousewheel', function(e, d) {

//This is js question which I don't understand often - What is 'this'?
//Second question. What is d?
    if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
      alert(this.scrollTop);
    }
  });

});

The html is quite messy. I make it simple here

<div class="folder">
   <div class="header"></div>
   <div class="medium-folder-body">
     <ul class="photo-lists></ul>
   </div>
   <div class="footer"></div>
</div>

folder-body css height:500px overflow-y:scroll

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
vzhen
  • 11,137
  • 13
  • 56
  • 87
  • @ExplosionPills Html added the html quite messy, I make it simple – vzhen Jan 27 '13 at 00:07
  • @ExplosionPills Forgot to mention, scrolling to top working, but reached bottom not working means will scroll the parent – vzhen Jan 27 '13 at 00:15
  • @ExplosionPills What does it mean? http://jsbin.com/ixura3 It actually prevented. Just mine not working – vzhen Jan 27 '13 at 00:17

1 Answers1

1

You're not including the additional plugin that handles the mousewheel scroll direction data:

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

http://jsfiddle.net/ExplosionPIlls/ZQgfr/

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405