Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function (e) {
  2.     function preventDefault(e) {
  3.         e.preventDefault();
  4.     }
  5.  
  6.     var disableScroll = false;
  7.     var scrollPos = 0;
  8.  
  9.     function stopScroll() {
  10.         disableScroll = true;
  11.         scrollPos = $(window).scrollTop();
  12.         // document.body.addEventListener('touchmove', preventDefault, { passive: false });
  13.     }
  14.  
  15.     function enableScroll() {    
  16.         disableScroll = false;    
  17.         // document.body.removeEventListener('touchmove', preventDefault, { passive: false });  
  18.     }
  19.  
  20.     $(window).bind('scroll', function(){    
  21.         if(disableScroll) {
  22.             $(window).scrollTop(scrollPos);  
  23.         }
  24.     });
  25.  
  26.     $(window).bind('touchmove', function(){    
  27.         $(window).trigger('scroll');  
  28.     });
  29.  
  30.     $('#main').on('shown.bs.modal', '.modal', function (e) {
  31.         stopScroll();
  32.     });
  33.  
  34.     $('#main').on('hidden.bs.modal', '.modal', function (e) {
  35.          enableScroll();
  36.     });
  37. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement