1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-17 18:09:17 +00:00

run scroll check immediately

This commit is contained in:
William Martin
2025-04-25 09:55:06 -04:00
parent 75cfd1cfe6
commit a6d42bad7a

View File

@@ -1,7 +1,7 @@
import { CdkScrollable } from "@angular/cdk/scrolling";
import { Signal, inject, signal } from "@angular/core";
import { toObservable, toSignal } from "@angular/core/rxjs-interop";
import { map, switchMap } from "rxjs";
import { map, startWith, switchMap } from "rxjs";
export type ScrollState = {
/** `true` when the scrollbar is not at the top-most position */
@@ -23,6 +23,7 @@ export const hasScrolledFrom = (scrollable?: Signal<CdkScrollable>): Signal<Scro
const scrollState$ = scrollable$.pipe(
switchMap((_scrollable) =>
_scrollable.elementScrolled().pipe(
startWith(null),
map(() => ({
top: _scrollable.measureScrollOffset("top") > 0,
bottom: _scrollable.measureScrollOffset("bottom") > 0,