public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH yew-widget-toolkit v2 1/3] js-helper: add client-to-svg-coordinate conversion helper
Date: Tue,  5 May 2026 09:31:52 +0200	[thread overview]
Message-ID: <20260505073203.398548-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260505073203.398548-1-d.csapak@proxmox.com>

Doing this in rust would mean we have to expose additional web-sys
features or doing the binding ourselves. Also since error handling for
the necessary code would be longer than the actual two line javascript
code, just have a short helper here.

This will be used in the upcoming Map widget to convert from pointer
position to svg coordinates.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 js-helper-module.js | 7 +++++++
 src/lib.rs          | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/js-helper-module.js b/js-helper-module.js
index 838c987..53291f3 100644
--- a/js-helper-module.js
+++ b/js-helper-module.js
@@ -31,6 +31,12 @@ function toggle_popover(popover) {
     popover.togglePopover();
 }
 
+function client_to_svg_coords(svg, x, y) {
+    const pt = new DOMPoint(x, y);
+    const svgPt = pt.matrixTransform(svg.getScreenCTM().inverse());
+    return [svgPt.x, svgPt.y];
+}
+
 export {
     test_alert,
     show_dialog,
@@ -39,4 +45,5 @@ export {
     hide_popover,
     show_popover,
     toggle_popover,
+    client_to_svg_coords,
 };
diff --git a/src/lib.rs b/src/lib.rs
index d3ac6ea..bd51b0d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -297,6 +297,7 @@ extern "C" {
     pub fn show_popover(popover: web_sys::Node);
     pub fn hide_popover(popover: web_sys::Node);
     pub fn toggle_popover(popover: web_sys::Node);
+    pub fn client_to_svg_coords(svg: &web_sys::Node, x: f64, y: f64) -> Vec<f64>;
 }
 
 // Create wrapper which panics if called from target_arch!=wasm32
@@ -329,6 +330,10 @@ mod panic_wrapper {
     pub fn toggle_popover(_popover: web_sys::Node) {
         unreachable!()
     }
+    /// Calculate the svg coordinates from viewport ones
+    pub fn client_to_svg_coords(_svg: &web_sys::Node, _x: f64, _y: f64) -> Vec<f64> {
+        unreachable!()
+    }
 }
 
 // some helpers
-- 
2.47.3





  reply	other threads:[~2026-05-05  7:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-05  7:31 [PATCH datacenter-manager/yew-widget-toolkit/yew-widget-toolkit-assets v2 0/8] add a new map widget for custom views Dominik Csapak
2026-05-05  7:31 ` Dominik Csapak [this message]
2026-05-05  7:31 ` [PATCH yew-widget-toolkit v2 2/3] widget: charts: add interactive Map with zoom/pan and clustering Dominik Csapak
2026-05-05  7:31 ` [PATCH yew-widget-toolkit v2 3/3] widget: charts: add WorldMap with GeoJSON rendering Dominik Csapak
2026-05-05  7:31 ` [PATCH yew-widget-toolkit-assets v2 1/1] charts: add necessary classes for Map Dominik Csapak
2026-05-05  7:31 ` [PATCH datacenter-manager v2 1/4] lib/api/ui: add location property to remote config Dominik Csapak
2026-05-05  8:26   ` Thomas Lamprecht
2026-05-05  8:36     ` Dominik Csapak
2026-05-05  8:44       ` Thomas Lamprecht
2026-05-05  8:46         ` Dominik Csapak
2026-05-05  7:31 ` [PATCH datacenter-manager v2 2/4] lib/api: add new 'remote-list' info to the resource status Dominik Csapak
2026-05-05  7:31 ` [PATCH datacenter-manager v2 3/4] ui: add world map geojson update script Dominik Csapak
2026-05-05  7:31 ` [PATCH datacenter-manager v2 4/4] ui: views: add map component Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260505073203.398548-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal