src/core/util/util.js
function disableBodyScroll() {
        var documentElement = $document[0].documentElement;

        var prevDocumentStyle = documentElement.style.cssText || '';
        var prevBodyStyle = body.style.cssText || '';

        var viewportTop = $mdUtil.getViewportTop();
        $mdUtil.disableScrollAround._viewPortTop = viewportTop;
        var clientWidth = body.clientWidth;
        var hasVerticalScrollbar = body.scrollHeight > body.clientHeight + 1;

        // Scroll may be set on <html> element (for example by overflow-y: scroll)
        // but Chrome is reporting the scrollTop position always on <body>.
        // scrollElement will allow to restore the scrollTop position to proper target.
        var scrollElement = documentElement.scrollTop > 0 ? documentElement : body;

        if (hasVerticalScrollbar) {
          angular.element(body).css({
            position: 'fixed',
            width: '100%',
            top: -viewportTop + 'px'
          });
        }

        if (body.clientWidth < clientWidth) {
          body.style.overflow = 'hidden';
        }

        return function restoreScroll() {
          // Reset the inline style CSS to the previous.
          body.style.cssText = prevBodyStyle;
          documentElement.style.cssText = prevDocumentStyle;

          // The scroll position while being fixed
          scrollElement.scrollTop = viewportTop;
        };
      }
function disableBodyScroll() {
        var documentElement = $document[0].documentElement;

        var prevDocumentStyle = documentElement.style.cssText || '';
        var prevBodyStyle = body.style.cssText || '';

        var viewportTop = $mdUtil.getViewportTop();
        $mdUtil.disableScrollAround._viewPortTop = viewportTop;
        var clientWidth = body.clientWidth;
        var hasVerticalScrollbar = body.scrollHeight > body.clientHeight + 1;

        // Scroll may be set on <html> element (for example by overflow-y: scroll)
        // but Chrome is reporting the scrollTop position always on <body>.
        // scrollElement will allow to restore the scrollTop position to proper target.
        var scrollElement = documentElement.scrollTop > 0 ? documentElement : body;

        if (hasVerticalScrollbar) {
          angular.element(body).css({
            position: 'fixed',
            width: '100%',
            top: -viewportTop + 'px'
          });
        }

        if (body.clientWidth < clientWidth) {
          body.style.overflow = 'hidden';
        }

        return function restoreScroll() {
          // Reset the inline style CSS to the previous.
          body.style.cssText = prevBodyStyle;
          documentElement.style.cssText = prevDocumentStyle;

          // The scroll position while being fixed
          scrollElement.scrollTop = viewportTop;
        };
      }
function disableBodyScroll ( ) { var documentElement = $document [ 0 ] . documentElement ; var prevDocumentStyle = documentElement . style . cssText || '' ; var prevBodyStyle = body . style . cssText || '' ; var viewportTop = $mdUtil . getViewportTop ( ) ; $mdUtil . disableScrollAround . _viewPortTop = viewportTop ; var clientWidth = body . clientWidth ; var hasVerticalScrollbar = body . scrollHeight > body . clientHeight + 1 ; // Scroll may be set on <html> element (for example by overflow-y: scroll) // but Chrome is reporting the scrollTop position always on <body>. // scrollElement will allow to restore the scrollTop position to proper target. var scrollElement = documentElement . scrollTop > 0 ? documentElement : body ; if ( hasVerticalScrollbar ) { angular . element ( body ) . css ( { position : 'fixed' , width : '100%' , top : - viewportTop + 'px' } ) ; } if ( body . clientWidth < clientWidth ) { body . style . overflow = 'hidden' ; } return function restoreScroll ( ) { // Reset the inline style CSS to the previous. body . style . cssText = prevBodyStyle ; documentElement . style . cssText = prevDocumentStyle ; // The scroll position while being fixed scrollElement . scrollTop = viewportTop ; } ; }
Converts the body to a position fixed block and translate it to the proper scroll position
Converts the body to a position fixed block and translate it to the proper scroll position