Add selectable fullscreen orientation and an iPhone landscape overlay

This commit is contained in:
Jonathan Sykes
2026-10-04 02:19:44 +08:00
parent d43cce441b
commit 536555e12d
8 changed files with 205 additions and 50 deletions

View File

@@ -0,0 +1,17 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { normalize, rotation, coordinates } = require('./fullscreen-orientation');
test('orientation defaults and only rotates mismatched viewports', () => {
assert.equal(normalize('invalid'), 'auto');
assert.equal(rotation('auto', 390, 844), 0);
assert.equal(rotation('landscape', 390, 844), 90);
assert.equal(rotation('landscape', 844, 390), 0);
assert.equal(rotation('portrait', 844, 390), -90);
});
test('rotated touch coordinates preserve local seek and swipe axes', () => {
const rect = { left: 10, top: 20, right: 400, bottom: 864, width: 390, height: 844 };
assert.deepEqual(coordinates(400, 20, rect, 90), { x: 0, y: 0, width: 844, height: 390 });
assert.deepEqual(coordinates(10, 864, rect, 90), { x: 844, y: 390, width: 844, height: 390 });
assert.deepEqual(coordinates(10, 864, rect, -90), { x: 0, y: 0, width: 844, height: 390 });
assert.deepEqual(coordinates(205, 442, rect), { x: 195, y: 422, width: 390, height: 844 });
});