summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--lib/js/dom.nim8
2 files changed, 9 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 4ea436fb0..b661226be 100644
--- a/changelog.md
+++ b/changelog.md
@@ -13,6 +13,7 @@
 
 - Added `newStringUninit` to system, which creates a new string of length `len` like `newString` but with uninitialized content.
 - Added `hasDefaultValue` to `std/typetraits` to check if a type has a valid default value.
+- Added Viewport API for the JavaScript targets in the `dom` module.
 
 [//]: # "Deprecations:"
 
diff --git a/lib/js/dom.nim b/lib/js/dom.nim
index ceb0375b7..ba9b4159d 100644
--- a/lib/js/dom.nim
+++ b/lib/js/dom.nim
@@ -1832,3 +1832,11 @@ since (1, 7):
 
   proc matches*(self: Node; cssSelector: cstring): bool {.importjs: "(#.$1(#) || false)".}
     ## https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
+
+
+since (2, 1):
+  type VisualViewport* {.importc.} = ref object of EventTarget
+    offsetLeft*, offsetTop*, pageLeft*, pageTop*, width*, height*, scale*: float
+    onResize*, onScroll*: proc (event: Event) {.closure.}
+
+  func visualViewport*(self: Window): VisualViewport {.importjs: "#.$1", nodecl.}