Dual scrollbars and a collapsing toolbar

Currently immersed in the development of a photo gallery using AngularJS and Angular Material (expand to fullscreen to observe the issue).

var app = angular.module('app', ['ngMaterial']);
app.controller('TitleController', function($scope) {
  $scope.title = 'Gallery';
});
app.controller('GalleryCtrl', function($scope, $http, $q, $mdMedia, $mdDialog) {

  //https://material.angularjs.org/latest/demo/virtualRepeat
  $scope.Images = [],

    //add more images
    $scope.LoadMore = function() {
      for (i = 0; i < 25; i++) {
        var randomWidth = Math.round(Math.random() * (800 - 400) + 400);
        var randomHeight = Math.round(Math.random() * (800 - 400) + 400);

        $scope.Images.push({
          src: "http://placehold.it/" + randomWidth + "x" + randomHeight + "/",
          id: Math.round(Math.random() * 10000)
        });
      };
    }

  $scope.ShowDetails = function(ev, number) {
    var useFullScreen = ($mdMedia('sm') || $mdMedia('xs')) && $scope.customFullscreen;

    $mdDialog.show({
      controller: DialogController,
      templateUrl: 'Home/GetInfo?id=' + number,
      parent: angular.element(document.body),
      targetEvent: ev,
      clickOutsideToClose: true,
      fullscreen: useFullScreen
    })


    $scope.$watch(function() {
      return $mdMedia('xs') || $mdMedia('sm');
    }, function(wantsFullScreen) {
      $scope.customFullscreen = (wantsFullScreen === true);
    });

  };

  function DialogController($scope, $mdDialog) {
    $scope.hide = function() {
      $mdDialog.hide();
    };

    $scope.cancel = function() {
      $mdDialog.cancel();
    };

    $scope.answer = function(answer) {
      $mdDialog.hide(answer);
    };
  }

  //initial loading 
  $scope.LoadMore();
});
body {
  background: #eeeeee;
}
html {
  background: #eeeeee;
}
.gridListdemoBasicUsage md-grid-list {
  margin: 8px;
}
.gridListdemoBasicUsage .green {
  background: #b9f6ca;
}
.gridListdemoBasicUsage md-grid-tile {
  transition: all 400ms ease-out 50ms;
}
.responsiveImage {
  max-width: 100%;
  max-height: 100%;
}
md-content {
  background: #eeeeee;
  position: relative;
}
.fit {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
.toolbardemoScrollShrink .face {
  width: 48px;
  margin: 16px;
  border-radius: 48px;
  border: 1px solid #ddd;
}
.md-toolbar-tools {
  background-color: #259b24;
}
.dialogdemoBasicUsage #popupContainer {
  position: relative;
}
.dialogdemoBasicUsage .footer {
  width: 100%;
  text-align: center;
  margin-left: 20px;
}
.dialogdemoBasicUsage .footer,
.dialogdemoBasicUsage .footer > code {
  font-size: 0.8em;
  margin-top: 50px;
}
.dialogdemoBasicUsage button {
  width: 200px;
}
.dialogdemoBasicUsage div#status {
  color: #c60008;
}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.7/angular-material.min.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.7/angular-material.min.js"></script>

<body ng-app="app" ng-controller="GalleryCtrl as gc" ng-cloak="" id="popupContainer" class="gridListdemoBasicUsage dialogdemoBasicUsage">

  <md-toolbar md-scroll-shrink="" ng-if="true" ng-controller="TitleController">
    <div class="md-toolbar-tools">
      <h3><span>{{title}}</span></h3>
    </div>
  </md-toolbar>

  <md-content style="height:100vh" />
  <md-grid-list md-cols-xs="1" md-cols-sm="2" md-cols-md="4" md-cols-gt-md="6" md-row-height-gt-md="1:1" md-row-height="2:2" md-gutter="12px" md-gutter-gt-sm="8px">
    <md-grid-tile ng-click="ShowDetails($event, n.id)" ng-repeat="n in Images" class="green">
      <img class="responsiveImage" src="{{n.src}}">
      <md-grid-tile-footer>
        <h3>Photo number {{n.id}}</h3>
      </md-grid-tile-footer>
    </md-grid-tile>
  </md-grid-list>

  <section layout="row" layout-sm="column" layout-align="center center" layout-wrap="">
    <md-button class="md-raised md-primary" ng-click="LoadMore()">Primary</md-button>
  </section>
</body>

For a smooth experience, switch to fullscreen mode, scroll down to load additional images, and trigger a button press. The specific issue I encountered involves the toolbar's behavior during scrolling – aiming for it to vanish when the user scrolls down and reappear upon scrolling up. At present, two separate scrollbars appear, with only the right one influencing the toolbar, while the left scrollbar unexpectedly advances to the very bottom of the page.

The desired outcome revolves around having a singular visible scrollbar governing navigation within the entire gallery, simultaneously managing the visibility of the toolbar based on scroll direction. Seeking advice on achieving this streamlined functionality.

Answer №1

One solution could be to include overflow-y: hidden; in the css style for the body element.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The source 'http://localhost:3000' is not authorized to access the Twitter API

I am working on a web application that utilizes the Twitter API REST. On one of my pages, I have a list of Twitter accounts and a button to add a new account. When this button is clicked, it triggers a function in the Angular controller: // Function to ...

I aim to place my :after content in mobile view or lower resolutions

I have a testimonial section built with HTML and CSS. You can view the demo on JSFIDDLE HERE. In the mobile view, I am facing an issue where the ":after" content is not aligning properly or appears misplaced. I'm looking for ideas to ensure that it re ...

AngularJS directive ngShow not working properly

It seems like I'm encountering some scope issues that I can't seem to resolve. Here's a rundown of the problem: I'm trying to create a custom directive called "my-create-content" that will insert an "img" HTML template into the element ...

Allowance for text overflow on subsequent line

Below is the snippet of HTML code I am working with: <h4 class="clickbelow">This is a very long line that overflows onto a new line when the width is small.</h4> Here is the CSS that I have implemented: .clickbelow:before { content: url( ...

Expanding Headers with JavaScript

Looking to add a Stretchy Header Functionality similar to the one shown in this GIF: Currently, on iPhones WebView, my approach involves calling a Scope Function On Scroll (especially focusing on Rubberband Scrolling) and adjusting the Image Height with C ...

How can I eliminate the tiny white square located beneath the scrollbar track?

`::-webkit-scrollbar{ width: 12px; } body::-webkit-scrollbar-track{ background: #f1e9e9; border-radius: 10px; margin-block: 0.1875rem; } ::-webkit-scrollbar-thumb{ background-color: #582965; border-radius: 10px; border: 3px so ...

Revise the display to show the formatted value, while adjusting the model to reflect the

How can I update the model value to be "valueToFormat" after formatting input boxes based on the user's locale and storing the value in en-US locale on blur? I am able to format the fields correctly for the user to view, but struggling with updating t ...

How come a child element with a lower z-index than its parent doesn't appear behind the parent?

I'm currently investigating why a child element fails to appear behind its parent element when it has a lower z-index value than the parent. The issue seems to arise only when the default z-index value of the parent is modified. Let's consider a ...

Creating a Dynamic Login Panel Using HTML, CSS, and Jquery

Designing a dynamic sliding login panel utilizing Html, CSS, and jquery alongside various plugins. Check it out here: http://24.125.42.135/ When activated, the bar smoothly pushes down the content (click on the login option at the top right corner). This ...

Minimal - Combining a module with a parent component

To provide some background, I am utilizing bootstrap nav pills as triggers for bootstrap collapsibles. This is a simplified representation of the LESS code for bootstraps nav pills: .nav-pills { > li { // Active state &.active > a ...

Investigating a bug in compiling D3 directives within AngularJS testing

I am encountering an issue with my angularjs directive that contains D3 code. Everything works perfectly when used in the application, but when I compile it for testing purposes, some of the D3 code is generated twice - specifically, the nodes and paths. ...

I am curious about how to implement overflow:hidden along with position:sticky in React.js

My attempt to address the white space issue caused by a navbar I created led me to try using overflow:hidden. The navbar is generated using the Header component, and I desired for it to have a position: sticky attribute. However, I realized that I cannot ...

Tips on sending an object to an Angular directive

I received a directive that has this structure: .directive('navigation', ['$rootScope', '$i18next', function ($rootScope, $i18next) { return { bindToController: true, templateUrl: 'navig ...

angular: the world of guarantees and assistance

I'm struggling to grasp the concept of promises. I understand what they are supposed to do, but when it comes to writing or debugging them, I hit a roadblock. MyController.js (function() { angular.module('WizmoApp').controller('St ...

Is there anyone who can provide a straightforward solution (code) for < something basic?

I have learned a lot about programming, but I'm stuck on one thing. How can I make an image stay in place when clicked on? What I mean is that when you click and hold on the image, then move the cursor, the image moves with the cursor. What I want is ...

Challenges encountered with wrapper component functionality in Angular 6

I am currently working on creating a wrapper component for the saturn-datepicker in Angular. My plan is to use this wrapper component in multiple applications now and potentially switch it out with another datepicker in the future. Although new to Angular, ...

Place the div at the center within the header

I'm struggling to center the logo in my media query for screens below 479px. Whenever I use margin auto, the image gets pushed to the right by the browser. Here is what I have so far and any assistance would be greatly appreciated. HTML <div clas ...

What are some common reasons why CSS and Bootstrap code can unexpectedly break?

I have been working on two tabs (tab-one, tab-two) where one is visible and the other is hidden. However, there has been an issue where the code breaks between the bottom of tab-one and the top of tab-two, causing some portion of tab-two to be occasionally ...

For my website's navigation bar, I utilized Bootstrap 4. Despite my efforts, I encountered difficulty in modifying the background color of the enclosing div element

After experimenting with a few different options such as setting the background-color to transparent, rgba(0,0,0,0), and background: none; I found that when I used background-color: red or any other color, the color changed as expected. Below is the HTML ...

Initiating automatic downloading through callback function in Internet Explorer

When attempting to initiate a download in IE within an angular+node configuration, I encounter a problem. Here is my current procedure: Users click on a download button The node server is requested to send a file The node server creates the file and sen ...