Skip to content

Commit 72f023b

Browse files
authored
Merge pull request #26 from hellpirat/feature/add-scrollToWithOptions-to-window
Add scrollToWithOptions to window
2 parents 558c7d5 + 1e1213a commit 72f023b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Diff for: CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Done:
44
* Change all `send.pipe` externals to `send`, making them "t-first" (#16)
55
* Remove deprecated APIs
66
* `Window.getSelection` now returns an option, to better match the definition
7+
* Add scrollToWithOptions to window
78

89
Todo:
910
* Convert to rescript syntax
1011
* Convert more input types to `node_like` and `element_like` to improve usability
1112
* Consider switching to `namespace: true`, or otherwise improve the folder structure to avoid exposing the implementation modules
1213
* Correct bugs, reduce how much code is generated, add missing APIs
13-
* Switch this file to "keep a changelog" style or atlassian changesets
14+
* Switch this file to "keep a changelog" style or atlassian changesets

Diff for: lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ window.scrollBy(10.0, -10.0);
7272

7373
window.scrollTo(120.5, 300.3);
7474

75+
window.scrollTo({
76+
left: 1.0,
77+
top: 1.0,
78+
behavior: "smooth"
79+
});
80+
7581
window.stop();
7682

7783
window.onload = (function (param) {

Diff for: src/Webapi/Dom/Webapi__Dom__Window.res

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ module Impl = (
130130
@send
131131
external scrollTo: (t_window, float, float) => unit = "" /* experimental, CSSOM View module */
132132
@send external stop: t_window => unit = ""
133+
134+
@send external scrollToWithOptions: (T.t, {"top": float, "left": float, "behavior": string}) => unit = "scrollTo"
133135

134136
@send
135137
external addPopStateEventListener: (

Diff for: tests/Webapi/Dom/Webapi__Dom__Window__test.res

+1
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ let _ = window->Window.resizeTo(120, 300)
7171
let _ = window->Window.scroll(0.0, 0.0)
7272
let _ = window->Window.scrollBy(10.0, -10.0)
7373
let _ = window->Window.scrollTo(120.5, 300.3)
74+
let _ = window->Window.scrollToWithOptions({ "left": 1.0, "top": 1.0, "behavior": "smooth"})
7475
Window.stop(window)
7576
Window.setOnLoad(window, () => print_endline("load"))

0 commit comments

Comments
 (0)