Skip to content

Commit

Permalink
Add Visual Viewport API
Browse files Browse the repository at this point in the history
  • Loading branch information
mvaled committed Oct 10, 2024
1 parent bc2065b commit f96d8d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Webapi/Dom/Webapi__Dom__VisualViewport.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// Support for https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport

type t

@get external height: t => int = "height"
@get external width: t => int = "width"
@get external scale: t => float = "scale"
@get external offsetLeft: t => int = "offsetLeft"
@get external offsetTop: t => int = "offsetTop"
@get external pageLeft: t => int = "pageLeft"
@get external pageTop: t => int = "pageTop"

include Webapi__Dom__EventTarget.Impl({
type t = t
})
3 changes: 3 additions & 0 deletions src/Webapi/Dom/Webapi__Dom__Window.res
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ module Impl = (
@set
external setOnLoad: (t_window, unit => unit) => unit =
"onload" /* use addEventListener instead? */

/* VisualViewport API */
@get external visualViewport: t_window => Webapi__Dom__VisualViewport.t = "visualViewport"
}

type t = Dom.window
Expand Down

0 comments on commit f96d8d3

Please sign in to comment.