From 9e8dca83f93c68cf7fba620438d28c85a6fdf93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=A1zquez=20Acosta?= Date: Thu, 10 Oct 2024 10:31:51 +0200 Subject: [PATCH] Add Visual Viewport API --- src/Webapi/Dom/Webapi__Dom__VisualViewport.res | 15 +++++++++++++++ src/Webapi/Dom/Webapi__Dom__Window.res | 3 +++ src/Webapi/Webapi__Dom.res | 1 + 3 files changed, 19 insertions(+) create mode 100644 src/Webapi/Dom/Webapi__Dom__VisualViewport.res diff --git a/src/Webapi/Dom/Webapi__Dom__VisualViewport.res b/src/Webapi/Dom/Webapi__Dom__VisualViewport.res new file mode 100644 index 00000000..23dcb3f4 --- /dev/null +++ b/src/Webapi/Dom/Webapi__Dom__VisualViewport.res @@ -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 +}) diff --git a/src/Webapi/Dom/Webapi__Dom__Window.res b/src/Webapi/Dom/Webapi__Dom__Window.res index 02e510a0..82dfaa6e 100644 --- a/src/Webapi/Dom/Webapi__Dom__Window.res +++ b/src/Webapi/Dom/Webapi__Dom__Window.res @@ -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 diff --git a/src/Webapi/Webapi__Dom.res b/src/Webapi/Webapi__Dom.res index 3f95a650..33fde08a 100644 --- a/src/Webapi/Webapi__Dom.res +++ b/src/Webapi/Webapi__Dom.res @@ -77,6 +77,7 @@ module TransitionEvent = Webapi__Dom__TransitionEvent module TreeWalker = Webapi__Dom__TreeWalker module UiEvent = Webapi__Dom__UiEvent module ValidityState = Webapi__Dom__ValidityState +module VisualViewport = Webapi__Dom__VisualViewport module WebGlContextEvent = Webapi__Dom__WebGlContextEvent module WheelEvent = Webapi__Dom__WheelEvent module Window = Webapi__Dom__Window