Skip to main content
deleted 2 characters in body
Source Link
Dan
  • 23
  • 2

How about this? (If you're using jQuery)

window.onscrollvar $window = function$(window) {;
    var $body = $(window.document.body);

window.onscroll = function() {
    var overlay = $body.children(".ui-widget-overlay").first();
        
    // Check if the overlay is visible and
    // restore the previous scroll state
    if (overlay.is(":visible")) {
        var scrollPos = $body.data("scroll-pos") || { x: 0, y: 0 };
        window.scrollTo(scrollPos.x, scrollPos.y);
    }
    else {
        // Just store the scroll state
        $body.data("scroll-pos", { x: window$window.scrollXscrollLeft(), y: window$window.scrollYscrollTop() });
    }
};

How about this? (If you're using jQuery)

window.onscroll = function() {
    var $body = $(document.body);
    var overlay = $body.children(".ui-widget-overlay").first();
        
    // Check if the overlay is visible and
    // restore the previous scroll state
    if (overlay.is(":visible")) {
        var scrollPos = $body.data("scroll-pos") || { x: 0, y: 0 };
        window.scrollTo(scrollPos.x, scrollPos.y);
    }
    else {
        // Just store the scroll state
        $body.data("scroll-pos", { x: window.scrollX, y: window.scrollY });
    }
};

How about this? (If you're using jQuery)

var $window = $(window);
var $body = $(window.document.body);

window.onscroll = function() {
    var overlay = $body.children(".ui-widget-overlay").first();
        
    // Check if the overlay is visible and restore the previous scroll state
    if (overlay.is(":visible")) {
        var scrollPos = $body.data("scroll-pos") || { x: 0, y: 0 };
        window.scrollTo(scrollPos.x, scrollPos.y);
    }
    else {
        // Just store the scroll state
        $body.data("scroll-pos", { x: $window.scrollLeft(), y: $window.scrollTop() });
    }
};
Source Link
Dan
  • 23
  • 2

How about this? (If you're using jQuery)

window.onscroll = function() {
    var $body = $(document.body);
    var overlay = $body.children(".ui-widget-overlay").first();
        
    // Check if the overlay is visible and
    // restore the previous scroll state
    if (overlay.is(":visible")) {
        var scrollPos = $body.data("scroll-pos") || { x: 0, y: 0 };
        window.scrollTo(scrollPos.x, scrollPos.y);
    }
    else {
        // Just store the scroll state
        $body.data("scroll-pos", { x: window.scrollX, y: window.scrollY });
    }
};