! . . Album Hình . . !

Tìm kiếm Những Gì Bạn Thích !

1 tháng 3, 2017

Disable scroll of body when scroll to bottom of the child div

PROBLEM
Your body of the web show scroll bar and the child div of body has scroll bar. You want to prevent effect scroll of body when you scroll to the bottom of the child div by mouse wheel.

SOLUTION
Add this lib to the bottom of body: https://rawgit.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.js
Origin lib link: https://plugins.jquery.com/mousewheel/

JAVASCRIPT
$(function() {
  $('.container-scroll').bind('mousewheel', function(e, d) {
    var height=$(e.currentTarget).height(),
    scrollHeight= e.currentTarget.scrollHeight;  
    if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
      e.preventDefault();
    }
  });

});

Hướng dẫn đăng nhận xét của bạn

  • Nếu muốn đăng nhận xét của mình các bạn click vào "Xem và nhận xét ở đây" dưới mỗi bài đăng, sau đó hộp thoại xuất hiện bạn gõ vào những nhận xét của mình. thế là xong! cảm ơn các bạn đã ghé thăm blog của mình !