question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to use main scrollbar

See original GitHub issue

Your issue may already be reported! Please search on the issue track before creating one.

Expected Behavior

I guess is a question, I want only 1 scrollbard (main scrollbar like you have in echoesplayer, I check the code but I dont know how you make it to work like that)

Actual Behavior

If I not use infiniteScrollContainer, (scrolled) never triggered. So I make it work with the container but I get two scrollbars like is normal. image

Possible Solution

Steps To Reproduce / Demo (if applicable)

[ ] Please share a stackblitz or plunkr demo reproducing this issue
I’m using a fork of this project https://github.com/tomastrajan/angular-ngrx-material-starter

  • I have a lazyloaded module with routes

PetComponent

<div [@routeAnimations]="o.isActivated && o.activatedRoute.routeConfig.path">
    <router-outlet #o="outlet"></router-outlet>
</div>

PetRoutes

{
    path: '',
    component: PetsComponent,
    children: [
      {
        path: '',
        component: PetListVirtualComponent,
        pathMatch: 'full',
        data: { title: 'pets.menu.petlist' },
        canActivate: [AuthGuardService],
      }
    ]
  }

PetListVirtualComponent

<div class="container mt-4 mb-4">
    <ng-container *ngIf="pets$ | async as pets; else loadingPets">
        <ng-container *ngIf="totalPets$ | async as totalPets; else loadingPets">
            <div class="container mt-4 mb-4 main-pets">
                <div class="row">
                    <h1 class="main-heading">{{ 'pets.list.title' | translate }} Virtual Version</h1>
                </div>
                <div infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50"
                    [infiniteScrollContainer]="'.main-pets'" [fromRoot]="true" (scrolled)="onScroll(pets.length, totalPets)">
                    <div class="row" [ngClass]="routeAnimationsElements">
                        <div class="col-12 col-md-6 col-lg-3" *ngFor="let pet of pets ; let index = index; trackBy: petsTrackByFn"
                            data-testid="pets-list">
                            <mat-card>
                                <a (click)="onViewPet(pet.id)">
                                    <mat-card-header>
                                        <mat-card-title>{{pet.name}}</mat-card-title>
                                        <mat-card-subtitle>{{pet.type}}</mat-card-subtitle>
                                    </mat-card-header>
                                    <img mat-card-image src="http://localhost:4000/{{pet.imageUrls[0].path}}" alt="Photo of a {{pet.name}}">
                                </a>
                                <mat-card-actions>
                                    <button mat-button [ngClass]="routeAnimationsElements">{{ 'pets.list.like' |
                                        translate
                                        |
                                        uppercase }}</button>
                                </mat-card-actions>
                            </mat-card>
                        </div>
                    </div>
                    <div *ngIf="loading && !empty" class="row justify-content-center">
                        <mat-spinner></mat-spinner>
                    </div>
                </div>
                <div class="row justify-content-center" *ngIf="empty">
                    <h3>Not more data!</h3>
                </div>
            </div>
        </ng-container>
    </ng-container>
    <ng-template #loadingPets>
        <div class="row justify-content-center">
            <mat-spinner></mat-spinner>
        </div>
    </ng-template>
    <div class="row justify-content-center">
        <div class="col-12 col-md-3">
            <button mat-raised-button color="primary" (click)="onCreatePet()" style="width:100%" [ngClass]="routeAnimationsElements"
                data-testid="pets-create-button">{{
                'pets.list.create' | translate }}</button>
        </div>
    </div>
</div>

CSS

.main-pets {
  height: 100vh;
  overflow-y: scroll;
}

Context

Your Environment

  • Version used: Angular 7
  • Browser Name and version: chrome
  • (Optional) Operating System and version (desktop or mobile):
  • (Optional) Link to your project: If is needed I can share you my repo 👍

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
anthowmcommented, Jan 22, 2019

I make it work 💃 thanks ! In case someone get someone like this, the problem is angular material add some style for scroll named ‘.mat-drawer-content’ so my final code is like this

<div infiniteScroll [infiniteScrollDistance]="2" [infiniteScrollThrottle]="50" (scrolled)="onScroll(pets.length, totalPets)"
                    [infiniteScrollContainer]="'.mat-drawer-content'" [fromRoot]="true">{content}</div>
0reactions
rajat29guptacommented, Aug 29, 2021

[fromRoot]=“true”

Thank you so much, It work for me 😃 I was stuck for 5 hours on this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

div scroll with main scrollbar - Stack Overflow
Basically, you can either scroll the whole page with the browser scroll bar, or you can scroll the div content with the div...
Read more >
scrollbar - CSS-Tricks
::-webkit-scrollbar-thumb addresses the draggable scrolling element that resizes depending on the size of the scrollable element; ::-webkit- ...
Read more >
::-webkit-scrollbar - CSS: Cascading Style Sheets | MDN
CSS Scrollbar Selectors. You can use the following pseudo-elements to customize various parts of the scrollbar for WebKit browsers:.
Read more >
How To Customize the Browser's Scrollbar with CSS
Firstly, we set the .scrollbar (class) width, height, background-color , then set overflow-y: scroll to get the vertical scrollbar.
Read more >
How To Create a Custom Scrollbar - W3Schools
Scrollbar Selectors. For webkit browsers, you can use the following pseudo elements to customize the browser's scrollbar: ::-webkit-scrollbar the scrollbar.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found