{"id":17143773,"url":"https://github.com/harttle/scroll-restoration-demos","last_synced_at":"2026-01-05T14:23:14.196Z","repository":{"id":66077785,"uuid":"124028019","full_name":"harttle/scroll-restoration-demos","owner":"harttle","description":"Demo for navigation-related browser bugs, scroll restoration, script caching, swipe gestures.","archived":false,"fork":false,"pushed_at":"2018-06-22T12:39:57.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T15:13:12.070Z","etag":null,"topics":["popstate","scroll-event","scrollrestoration","scrolly"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harttle.png","metadata":{"files":{"readme":"README.md","changelog":"history-restoration-timing.html","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-06T05:52:28.000Z","updated_at":"2021-09-25T15:41:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"91902afe-1b71-4ab8-905c-eb272c9c425f","html_url":"https://github.com/harttle/scroll-restoration-demos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harttle%2Fscroll-restoration-demos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harttle%2Fscroll-restoration-demos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harttle%2Fscroll-restoration-demos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harttle%2Fscroll-restoration-demos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harttle","download_url":"https://codeload.github.com/harttle/scroll-restoration-demos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245247952,"owners_count":20584446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["popstate","scroll-event","scrollrestoration","scrolly"],"created_at":"2024-10-14T20:42:17.640Z","updated_at":"2026-01-05T14:23:14.157Z","avatar_url":"https://github.com/harttle.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"## history.scrollRestoration ALSO Affects External Links\n\nTypically, you want set `history.scrollRestoration` to `manual` to allow custom transitions.\n\nThis API applies to the current entry,\nwhich means the scroll state will also NOT be restored when navigating back from external links.\n\n* Demo: http://harttle.github.io/scroll-restoration-demos/history-restoration.html\n* Tutorial: https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration\n* Spec: https://majido.github.io/scroll-restoration-proposal/history-based-api.html\n\n## Scroll Restoration Happens AFTER `popstate`\n\nThis means you can always get current scroll position on popstate,\nbut probably not in async callbacks (e.g. Promises).\nThe actual restoration timing is implementation-related:\nIt takes one [animation frame][requestAnimationFrame] in Chrome, and several more in Safari.\n\n* Demo: http://harttle.github.io/scroll-restoration-demos/history-restoration-timing.html\n\n## Get Scroll Position\n\nTo get scroll position, there's many APIs with different compatibility issues such as:\n\n* `window.scrollY`\n* `window.pageYOffset`\n* `document.body.scrollTop`\n* `document.documentElement.scrollTop`\n* `document.scrollingElement.scrollTop`\n\nHere we don't examine these APIs one by one, here's a demo to test with:\n\n* Demo: http://harttle.github.io/scroll-restoration-demos/scroll-apis.html\n* Tutorial: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY\n\n## NEVER Set scrollY or pageYOffset\n\nAlways use `scrollTo` to scroll your page.\nThrough `scrollY` and `pageYOffset` are NOT readonly, which means they can be set,\nthey WON'T change anymore once assigned. Take care!\n\n* Tutorial: https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll\n\n## scroll event not fired on UIWebview\n\nTypically `scroll` event will be fired on scroll restoration. \nWhereas for iOS UIWebview-based browsers no `scroll` event will be fired.\nTry UC browser, Baidubox browser.\n\n* Demo: http://harttle.github.io/scroll-restoration-demos/scroll-event.html\n\n[requestAnimationFrame]: https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharttle%2Fscroll-restoration-demos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharttle%2Fscroll-restoration-demos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharttle%2Fscroll-restoration-demos/lists"}