June.

12월 안에는 꼭...

Portfolio

About

Remembering the user's scroll position (for History.scrollRestoration)

2023/01/15
짧.

1 min read

Remembering the user's scroll position (for History.scrollRestoration)

Locales:

en

ko

tl;dr

You can set whether the page should return to where it was originally scrolled when the user presses the back button.

1const scrollRestoration = history.scrollRestoration; 2if (scrollRestoration === "manual") { 3 console.log( 4 "If the option is set to manual, the scroll position will not be restored and the user will have to move it manually." 5 ); 6}

Scroll Restoration

This section is about Scroll Restoration, the browser History API for scroll restoration. This API allows you to set whether the page should return to the original scroll position when the user presses the browser's back button.

The default is auto, and setting this to manual will not restore the scrolled position.

1// Restore the user's scroll position on the page. 2history.scrollRestoration = "auto"; // default 3 4// The position on the page is not restored and the user must manually scroll to that position. 5history.scrollRestoration = "manual";

See also.

  • MDN Web Docs History API scrollRestoration

Translated with www.DeepL.com/Translator (free version)

관련 포스트가 4개 있어요.

useSyncExternalStore가 무엇일까?

짧.
react-use-sync-external-store cover image
2023/10/23 (updated)

React 18 useSyncExternalStore에 대해서

CSS flex box의 align-items의 flex-start와 baseline의 차이점에 대해서

짧.
css-flex-box-align-items-attributes cover image
2023/09/24

CSS에서 align-items의 flex-start와 baseline의 차이점

React 18.0.0 react-dom의 flushSync의 사용법과 주의사항에 대해서 알아보자.

짧.
react-flush-sync cover image
2023/09/24

React flushSync에 대해서

maxLength를 넣고 이모지를 넣으면 브라우저마다 계산되는 것이 다르다.

짧.
html-input-max-length cover image
2023/09/15

HTML `<input />`의 maxLength 동작이 safari에서 다른 이슈

profile

정현수.

Currently Managed

Currently not managed

© 2024. junghyeonsu all rights reserved.