weavesignal/packages/ui/fixed.ts
The WeaveSignal contributors 0a3596480b WeaveSignal 1.0.1
What was built after 1.0.0; CHANGELOG.md has the detail, and deploy/cloudron/CHANGELOG.md the
package's.

- Fixed: the desktop studio app on Linux could not send anything with a body (its content
  security policy blocked Tauri's IPC), so invitations failed. Update the app.
- Browser cameras reach the desk: a Chromium browser's AV1 camera is unpacked, sent at one
  picture size, survives packet loss, and has a jitter buffer of its own (300 ms).
- The one-key DJ handover, a show's presenter and takedown contact, Icecast out and RTMP out
  (Rumble, Odysee, PeerTube, any RTMP server), video in the Cloudron package.
- Two MP3 streams for the listener to choose from, the Opus rate as a setting, chat hours.
- Avatars, pictures and documents in the chat, each approved by staff first.
- Install wizards on the website and a setup page on the station with its own look.
- A Night theme in the studio app.
- Fixes from the public tracker: issues 2-7, 10, 13 and 14.
2026-11-12 10:20:19 +00:00

25 lines
1.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: 2026 The WeaveSignal contributors
/**
* How many viewport pixels one CSS pixel of a `position: fixed` element's `left` or `top` moves it.
*
* The studio's text size (A− and A+ in the frame) is CSS `zoom` on `<html>`. Under it
* `getBoundingClientRect` and `innerWidth` answer in viewport pixels, while a fixed element's
* `left`, `top` and `max-width` are CSS pixels that the zoom then scales. A tip placed at a rect's
* coordinates therefore lands zoom times too far right and down, and near the window's right edge
* runs off it (WebKitGTK 4.1, measured 2026-11-11: at 130 % a chip at x 650 put its tip at 845).
* Divide every length written to the element's style by this figure.
*
* Measured rather than read from the zoom, so it holds in any engine and with no zoom at all.
* Leaves the element at left 0, top 0.
*/
export function fixedScale(el: HTMLElement): number {
el.style.top = '0px';
el.style.left = '100px';
const at100 = el.getBoundingClientRect().left;
el.style.left = '0px';
const at0 = el.getBoundingClientRect().left;
const s = (at100 - at0) / 100;
return s > 0 && Number.isFinite(s) ? s : 1;
}