Simplebar: Does simplebar work with angular material's virtual scrolling?

Created on 1 May 2020  路  2Comments  路  Source: Grsmto/simplebar

Just tried using the ngx-simplebar component inside cdk-virtual-scroll-viewport (which is used for virtual scrolling) and it didn't hide the scroll bar.

Does Simplebar support such a usage?

P.S. : package.json

   "@angular/animations": "^8.2.13",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "~8.2.13",
    "@angular/core": "~8.2.13",
    "@angular/material": "^8.2.3",
    ...
    "simplebar-angular": "^2.1.0",
    ...
question

Most helpful comment

@amoghskulkarni I'm trying to achieve something similar, I think it will be difficult considering we can't wrap the simplebar around Angular's cdk-virtual-scroll-viewport, as the height of the viewport is not that of all the elements in the list, but what's in the viewport.

I ended up just creating a mixin to style my components, I have tested this on MacOS, Firefox and Chrome:

$thumb-color: #969699;
$radius: 4px;

@mixin scrollable {
  scrollbar-track-color: transparent;
  scrollbar-color: $thumb-color transparent;
  overflow-y: scroll;
  scrollbar-width: thin;
  &::-webkit-scrollbar {
    height: 10px;
    width: 6px;
    border-radius: $radius;
    background: transparent;
    transition: all 0.3s ease;
  }
  &::-webkit-scrollbar:hover {
    background: #c6c7ca;
  }
  &::-webkit-scrollbar-thumb {
    background: $thumb-color;
    border-radius: $radius;
  }
}

Hope this helps.

All 2 comments

@amoghskulkarni I'm trying to achieve something similar, I think it will be difficult considering we can't wrap the simplebar around Angular's cdk-virtual-scroll-viewport, as the height of the viewport is not that of all the elements in the list, but what's in the viewport.

I ended up just creating a mixin to style my components, I have tested this on MacOS, Firefox and Chrome:

$thumb-color: #969699;
$radius: 4px;

@mixin scrollable {
  scrollbar-track-color: transparent;
  scrollbar-color: $thumb-color transparent;
  overflow-y: scroll;
  scrollbar-width: thin;
  &::-webkit-scrollbar {
    height: 10px;
    width: 6px;
    border-radius: $radius;
    background: transparent;
    transition: all 0.3s ease;
  }
  &::-webkit-scrollbar:hover {
    background: #c6c7ca;
  }
  &::-webkit-scrollbar-thumb {
    background: $thumb-color;
    border-radius: $radius;
  }
}

Hope this helps.

@jakerenzella Thanks a lot for the comment, I eventually ended up doing something very similar to what you pointed out. I was just curious if it was possible to use Simplebar's other features too.

Thanks for the help regardless!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aleksandr2015 picture Aleksandr2015  路  6Comments

FuturFuturFutur picture FuturFuturFutur  路  4Comments

danielg42 picture danielg42  路  5Comments

apopelyshev picture apopelyshev  路  7Comments

barnu5 picture barnu5  路  5Comments