0

So I am using this code to perform tasks when the user scrolls:

function myFunction(){
var position = $(window).scrollTop();

$(window).scroll(function() {
    var scroll = $(window).scrollTop();
    if(scroll > position) {
         // scrolling downwards
         hypeDocument.showSceneNamed('Section 2', hypeDocument.kSceneTransitionCrossfade, 1.1);
    }
    position = scroll;
});

return false;
}

But I would like to prevent down scrolling on one page. Is there anyway I can do this whilst allowing the scroll on the other pages? I tried using $(window).off("scroll"); but that blocks scrolling in both directions.

dwinnbrown
  • 3,789
  • 9
  • 35
  • 60

2 Answers2

0

This will completely disable scrolling:

$('html, body').css({
    'overflow': 'hidden',
    'height': '100%'
});

To restore:

$('html, body').css({
    'overflow': 'auto',
    'height': 'auto'
});
Ducky
  • 184
  • 15
0

If you only wish to prevent scrolling in the vertical direction (up and down), you can set the scroll in that direction to hidden:

overflow-y: hidden

You could trigger that effect with jQuery using:

$('body').css('overflow-y','hidden');

Carl K
  • 974
  • 7
  • 18