diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index 0c7e86bb3..c60d6fe8f 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -14486,6 +14486,7 @@ History[JC] def pushState(statedata: js.Any, title: String): Unit History[JC] def pushState(statedata: js.Any, title: String, url: String): Unit History[JC] def replaceState(statedata: js.Any, title: String): Unit History[JC] def replaceState(statedata: js.Any, title: String, url: String): Unit +History[JC] var scrollRestoration: ScrollRestoration History[JC] def state: js.Any HkdfCtrParams[JT] val context: BufferSource HkdfCtrParams[JT] val hash: HashAlgorithmIdentifier @@ -24703,6 +24704,9 @@ Screen[JC] def colorDepth: Int Screen[JC] def height: Double Screen[JC] def pixelDepth: Int Screen[JC] def width: Double +ScrollRestoration[JT] +ScrollRestoration[SO] val auto: ScrollRestoration +ScrollRestoration[SO] val manual: ScrollRestoration Selection[JC] def addRange(range: Range): Unit Selection[JC] def anchorNode: Node Selection[JC] def anchorOffset: Int diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index 0c7e86bb3..c60d6fe8f 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -14486,6 +14486,7 @@ History[JC] def pushState(statedata: js.Any, title: String): Unit History[JC] def pushState(statedata: js.Any, title: String, url: String): Unit History[JC] def replaceState(statedata: js.Any, title: String): Unit History[JC] def replaceState(statedata: js.Any, title: String, url: String): Unit +History[JC] var scrollRestoration: ScrollRestoration History[JC] def state: js.Any HkdfCtrParams[JT] val context: BufferSource HkdfCtrParams[JT] val hash: HashAlgorithmIdentifier @@ -24703,6 +24704,9 @@ Screen[JC] def colorDepth: Int Screen[JC] def height: Double Screen[JC] def pixelDepth: Int Screen[JC] def width: Double +ScrollRestoration[JT] +ScrollRestoration[SO] val auto: ScrollRestoration +ScrollRestoration[SO] val manual: ScrollRestoration Selection[JC] def addRange(range: Range): Unit Selection[JC] def anchorNode: Node Selection[JC] def anchorOffset: Int diff --git a/dom/src/main/scala-2/org/scalajs/dom/ScrollRestoration.scala b/dom/src/main/scala-2/org/scalajs/dom/ScrollRestoration.scala new file mode 100644 index 000000000..751cd4904 --- /dev/null +++ b/dom/src/main/scala-2/org/scalajs/dom/ScrollRestoration.scala @@ -0,0 +1,17 @@ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +sealed trait ScrollRestoration extends js.Any + +/** + * see [[https://html.spec.whatwg.org/multipage/history.html#the-history-interface]] + * which contains the spec for ScrollRestoration + */ +object ScrollRestoration { + /** The location on the page to which the user has scrolled will be restored. */ + val auto: ScrollRestoration = "auto".asInstanceOf[ScrollRestoration] + /** The location on the page is not restored. The user will have to scroll to the location manually. */ + val manual: ScrollRestoration = "manual".asInstanceOf[ScrollRestoration] +} diff --git a/dom/src/main/scala-3/org/scalajs/dom/ScrollRestoration.scala b/dom/src/main/scala-3/org/scalajs/dom/ScrollRestoration.scala new file mode 100644 index 000000000..5eb2e14ee --- /dev/null +++ b/dom/src/main/scala-3/org/scalajs/dom/ScrollRestoration.scala @@ -0,0 +1,16 @@ +package org.scalajs.dom + +import scala.scalajs.js + +opaque type ScrollRestoration <: String = String + +/** + * see [[https://html.spec.whatwg.org/multipage/history.html#the-history-interface]] + * which contains the spec for ScrollRestoration + */ +object ScrollRestoration { + /** The location on the page to which the user has scrolled will be restored. */ + val auto: ScrollRestoration = "auto" + /** The location on the page is not restored. The user will have to scroll to the location manually. */ + val manual: ScrollRestoration = "manual" +} diff --git a/dom/src/main/scala/org/scalajs/dom/History.scala b/dom/src/main/scala/org/scalajs/dom/History.scala index 83219f1d6..0fcd918c4 100644 --- a/dom/src/main/scala/org/scalajs/dom/History.scala +++ b/dom/src/main/scala/org/scalajs/dom/History.scala @@ -71,4 +71,9 @@ class History extends js.Object { * safely passed. */ def pushState(statedata: js.Any, title: String): Unit = js.native + + /** The `scrollRestoration` property of [[History]] interface allows web applications to explicitly set default scroll + * restoration behavior on history navigation. + */ + var scrollRestoration: ScrollRestoration = js.native }