2

I open a partial view in an overlay using jquery (showing a fixed div and disable scrolling for the underlying webpage). This seems to work in chromium and firefox on the desktop, and also in chrome for android, but not in firefox/android:

$('a#manage-albums').click(function(){
    $.get( this.href )
        .done(function( data ) {
            $('div#flvr-overlay-content').html(data);
            $('div#flvr-overlay-back').show();
            $('html,body').css('overflow-y','hidden');
        });
    return false;
});

The overlay appears and shows its content, is fixed and everything looks good, but I can still scroll the underlying webpage..

I also have this meta tag in use, if that matters:

<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0, user-scalable=no" />

How can I disable scrolling (overflow-y) also for firefox on android?

edit:

It looks as if firefox does not like the 'overflow-y'.

With this line:

$('html,body').css('overflow','hidden');`

the scrolling seems to be stopped / reduced to the height of the firefox menu bar.

haheute
  • 2,129
  • 3
  • 32
  • 49
  • it is a HTML/PHP/JQuery website. I don't know what a webview is. – haheute Aug 07 '15 at 17:52
  • I fought against this problem yesterday and gave up eventually and removed my modals from mobile. But some have said that adding `position: fixed` to body and/or html could work. I didn't test it, though. – Bruno Henrique Aug 07 '15 at 18:09
  • I have tried `$('html,body').css('overflow-y','hidden').css('position','fixed');` Nothing changed – haheute Aug 07 '15 at 18:18
  • I'm not sure, but maybe adding overflow: hidden !important to all elements with * selector could work, and then add overflow: auto !important to your album element. Not a pretty solution, but may work. – Bruno Henrique Aug 07 '15 at 18:27
  • @haheute well did you get it to work? an accept/upvote or both would be nice! – Rachel Gallen Aug 07 '15 at 19:15
  • not really. I did something different and used `overflow` instead of `overflow-y`. perhaps it is a firefox bug, I don't know – haheute Aug 07 '15 at 19:23

1 Answers1

0

there are a number of ways to do it, first try

gridview.setOnTouchListener(new OnTouchListener(){

@Override
public boolean onTouch(View v, MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_MOVE){
        return true;
    }
    return false;
}

});

thats for a gridview.

Source

for a scrollview use "verticalScrollDisabled = true"

or use (javascript)

document.body.addEventListener('touchmove', function(e){ e.preventDefault(); });

or jquery

$(document).bind('touchmove', function(e) {
    e.preventDefault();
});

failing that use $("body").css("overflow", "hidden!important"); and that should work

Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
  • I have tried `$('html,body').attr('style', 'overflow-y: hidden !important');` . That did not help. What I don't understand is, why chrome does it, and firefox on my PC does it as well. Only firefox/android still scrolls. Something must be different there.. – haheute Aug 07 '15 at 18:04
  • Not yet. I don't know where and what·and think it should work using jquery and css. – haheute Aug 07 '15 at 18:07
  • added a jquery answer – Rachel Gallen Aug 07 '15 at 18:13
  • you're too fast ;) I would also like to understand why it is not working in firefox/android – haheute Aug 07 '15 at 18:20
  • 1
    you should visit caniuse.com some things are not compatible with all browsers. Firefox has serious issues! – Rachel Gallen Aug 07 '15 at 18:22