packageDocumentation module import { IDisposable } from "@itwin/core-bentley" ; public export class ScrollPositionMaintainer implements IDisposable { private _storage : Map < Element , number > ; public constructor ( el ) { this . _storage = new Map ( ) ; ScrollPositionMaintainer . saveScrollPositions ( [ el ] , this . _storage ) ; } public dispose ( ) { ScrollPositionMaintainer . restoreScrollPositions ( this . _storage ) ; } private static saveScrollPositions ( elems , storage ) { for ( const el of elems ) { if ( el . scrollTop ) storage . set ( el , el . scrollTop ) ; if ( el . children ) this . saveScrollPositions ( el . children , storage ) ; } } private static restoreScrollPositions ( storage ) { storage . forEach ( ( scrollTop , el ) => el . scrollTop = scrollTop ) ; } }