Skip to content

Commit ffcbaa9

Browse files
authored
Merge pull request #718 from zetashift/add-facade/scrollrestoration
Add `History#scrollRestoration`
2 parents 9e0541c + c11aedf commit ffcbaa9

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

api-reports/2_12.txt

+4
Original file line numberDiff line numberDiff line change
@@ -14486,6 +14486,7 @@ History[JC] def pushState(statedata: js.Any, title: String): Unit
1448614486
History[JC] def pushState(statedata: js.Any, title: String, url: String): Unit
1448714487
History[JC] def replaceState(statedata: js.Any, title: String): Unit
1448814488
History[JC] def replaceState(statedata: js.Any, title: String, url: String): Unit
14489+
History[JC] var scrollRestoration: ScrollRestoration
1448914490
History[JC] def state: js.Any
1449014491
HkdfCtrParams[JT] val context: BufferSource
1449114492
HkdfCtrParams[JT] val hash: HashAlgorithmIdentifier
@@ -24703,6 +24704,9 @@ Screen[JC] def colorDepth: Int
2470324704
Screen[JC] def height: Double
2470424705
Screen[JC] def pixelDepth: Int
2470524706
Screen[JC] def width: Double
24707+
ScrollRestoration[JT]
24708+
ScrollRestoration[SO] val auto: ScrollRestoration
24709+
ScrollRestoration[SO] val manual: ScrollRestoration
2470624710
Selection[JC] def addRange(range: Range): Unit
2470724711
Selection[JC] def anchorNode: Node
2470824712
Selection[JC] def anchorOffset: Int

api-reports/2_13.txt

+4
Original file line numberDiff line numberDiff line change
@@ -14486,6 +14486,7 @@ History[JC] def pushState(statedata: js.Any, title: String): Unit
1448614486
History[JC] def pushState(statedata: js.Any, title: String, url: String): Unit
1448714487
History[JC] def replaceState(statedata: js.Any, title: String): Unit
1448814488
History[JC] def replaceState(statedata: js.Any, title: String, url: String): Unit
14489+
History[JC] var scrollRestoration: ScrollRestoration
1448914490
History[JC] def state: js.Any
1449014491
HkdfCtrParams[JT] val context: BufferSource
1449114492
HkdfCtrParams[JT] val hash: HashAlgorithmIdentifier
@@ -24703,6 +24704,9 @@ Screen[JC] def colorDepth: Int
2470324704
Screen[JC] def height: Double
2470424705
Screen[JC] def pixelDepth: Int
2470524706
Screen[JC] def width: Double
24707+
ScrollRestoration[JT]
24708+
ScrollRestoration[SO] val auto: ScrollRestoration
24709+
ScrollRestoration[SO] val manual: ScrollRestoration
2470624710
Selection[JC] def addRange(range: Range): Unit
2470724711
Selection[JC] def anchorNode: Node
2470824712
Selection[JC] def anchorOffset: Int
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
@js.native
6+
sealed trait ScrollRestoration extends js.Any
7+
8+
/**
9+
* see [[https://html.spec.whatwg.org/multipage/history.html#the-history-interface]]
10+
* which contains the spec for ScrollRestoration
11+
*/
12+
object ScrollRestoration {
13+
/** The location on the page to which the user has scrolled will be restored. */
14+
val auto: ScrollRestoration = "auto".asInstanceOf[ScrollRestoration]
15+
/** The location on the page is not restored. The user will have to scroll to the location manually. */
16+
val manual: ScrollRestoration = "manual".asInstanceOf[ScrollRestoration]
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
opaque type ScrollRestoration <: String = String
6+
7+
/**
8+
* see [[https://html.spec.whatwg.org/multipage/history.html#the-history-interface]]
9+
* which contains the spec for ScrollRestoration
10+
*/
11+
object ScrollRestoration {
12+
/** The location on the page to which the user has scrolled will be restored. */
13+
val auto: ScrollRestoration = "auto"
14+
/** The location on the page is not restored. The user will have to scroll to the location manually. */
15+
val manual: ScrollRestoration = "manual"
16+
}

dom/src/main/scala/org/scalajs/dom/History.scala

+5
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ class History extends js.Object {
7171
* safely passed.
7272
*/
7373
def pushState(statedata: js.Any, title: String): Unit = js.native
74+
75+
/** The `scrollRestoration` property of [[History]] interface allows web applications to explicitly set default scroll
76+
* restoration behavior on history navigation.
77+
*/
78+
var scrollRestoration: ScrollRestoration = js.native
7479
}

0 commit comments

Comments
 (0)