summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJuan Carlos <juancarlospaco@gmail.com>2023-09-28 02:37:09 -0300
committerGitHub <noreply@github.com>2023-09-28 07:37:09 +0200
commitf0865fa6960cbff301318f4ef8d603052519b24d (patch)
tree680206bccbae4248cf1351b851ff64a1d18919e3
parenta9e6660a74322f0385f22c89e60c46e3177c2513 (diff)
downloadNim-f0865fa6960cbff301318f4ef8d603052519b24d.tar.gz
Fix #21407 (#22759)
- Fix #21407

---------

Co-authored-by: Amjad Ben Hedhili <amjadhedhili@outlook.com>
-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.}