mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Throttle replace state in restore scroll (#16693)
This commit is contained in:
parent
9b896c63b6
commit
2219c9bbd3
@ -1,5 +1,10 @@
|
|||||||
import type { LitElement } from "lit";
|
import type { LitElement } from "lit";
|
||||||
import type { ClassElement } from "../../types";
|
import type { ClassElement } from "../../types";
|
||||||
|
import { throttle } from "../util/throttle";
|
||||||
|
|
||||||
|
const throttleReplaceState = throttle((value) => {
|
||||||
|
history.replaceState({ scrollPosition: value }, "");
|
||||||
|
}, 300);
|
||||||
|
|
||||||
export const restoreScroll =
|
export const restoreScroll =
|
||||||
(selector: string): any =>
|
(selector: string): any =>
|
||||||
@ -9,7 +14,7 @@ export const restoreScroll =
|
|||||||
key: element.key,
|
key: element.key,
|
||||||
descriptor: {
|
descriptor: {
|
||||||
set(this: LitElement, value: number) {
|
set(this: LitElement, value: number) {
|
||||||
history.replaceState({ scrollPosition: value }, "");
|
throttleReplaceState(value);
|
||||||
this[`__${String(element.key)}`] = value;
|
this[`__${String(element.key)}`] = value;
|
||||||
},
|
},
|
||||||
get(this: LitElement) {
|
get(this: LitElement) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user