1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-08 20:50:28 +00:00

run scroll check immediately

This commit is contained in:
William Martin
2025-04-25 09:50:34 -04:00
parent 59bedc408e
commit 12dbb47b93

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,