import { Observable , combineLatest , distinctUntilKeyChanged , map } from "rxjs" ; import { Header } from "~/components" ; import { getElementOffset } from "../../element" ; import { Viewport } from "../_" ; /**
 * Watch options
 */ interface WatchOptions { viewport$ : Observable < Viewport > ; header$ : Observable < Header > ; } param el param options returns export function watchViewportAt ( el , { viewport$ , header$ } ) { const size$ = viewport$ . pipe ( distinctUntilKeyChanged ( "size" ) ) ; const offset$ = combineLatest ( [ size$ , header$ ] ) . pipe ( map ( ( ) => getElementOffset ( el ) ) ) ; return combineLatest ( [ header$ , viewport$ , offset$ ] ) . pipe ( map ( ( [ { height } , { offset , size } , { x , y } ] ) => ( { offset : { x : offset . x - x , y : offset . y - y + height } , size } ) ) ) ; }