WIP: Fix pan-zoom for webkit

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 22:41:31 -07:00
parent 3de614c8ee
commit 7b5fd7590b
8 changed files with 27 additions and 13 deletions

4
package-lock.json generated
View File

@ -5,7 +5,7 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"pan-zoom": "github:webdevcat-me/pan-zoom" "pan-zoom": "github:webdevcat-me/pan-zoom#transform-descendant"
}, },
"devDependencies": { "devDependencies": {
"esbuild": "^0.20.2", "esbuild": "^0.20.2",
@ -3820,7 +3820,7 @@
}, },
"node_modules/pan-zoom": { "node_modules/pan-zoom": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "git+ssh://git@github.com/webdevcat-me/pan-zoom.git#2d3fc1cd22ffcc61ec178eeaf97f3a4d7cba98bf" "resolved": "git+ssh://git@github.com/webdevcat-me/pan-zoom.git#d40c81c2c6aade48ca2de4376bd4f2bd7c3e56b3"
}, },
"node_modules/parent-module": { "node_modules/parent-module": {
"version": "1.0.1", "version": "1.0.1",

View File

@ -1,7 +1,7 @@
{ {
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"pan-zoom": "github:webdevcat-me/pan-zoom" "pan-zoom": "github:webdevcat-me/pan-zoom#transform-descendant"
}, },
"devDependencies": { "devDependencies": {
"esbuild": "^0.20.2", "esbuild": "^0.20.2",

View File

@ -210,10 +210,6 @@ g.selected use.primary-weapon {
fill: red; fill: red;
} }
.gameboard {
transform: translate(19px, 31px) scale(4);
}
/* Inradius and circumradius values come from the hexagon */ /* Inradius and circumradius values come from the hexagon */
.grid, g.start-locations { .grid, g.start-locations {
--inradius: 8.66px; --inradius: 8.66px;

View File

@ -155,7 +155,7 @@ button.set-firing-arc img {
} }
.soldier-record { .soldier-record {
display: inline-block; display: block;
position: relative; position: relative;
white-space: nowrap; white-space: nowrap;
background-color: white; background-color: white;
@ -260,6 +260,7 @@ div#content {
max-height: 100vh; max-height: 100vh;
flex-direction: column; flex-direction: column;
position: relative; position: relative;
min-width: 340px;
} }
#content > div:first-of-type { #content > div:first-of-type {
@ -452,4 +453,8 @@ div#dice {
#record-sheet > div:last-of-type > div { #record-sheet > div:last-of-type > div {
margin-left: 1px; margin-left: 1px;
} }
div#content {
min-width: 680px;
}
} }

View File

@ -45,9 +45,9 @@
<image id="counter-grenade" href="counter_grenade.jpg" width="10"/> <image id="counter-grenade" href="counter_grenade.jpg" width="10"/>
</defs> </defs>
<rect id="background"/>
<g class="gameboard"> <g class="gameboard">
<rect id="background"/>
<rect id="dots" fill="url(#asterisk)"/> <rect id="dots" fill="url(#asterisk)"/>
<g id="firing-arcs"> <g id="firing-arcs">

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -131,7 +131,7 @@ async function buildScenario(req) {
}); });
}); });
scenario.querySelectorAll('use.mapsheet').forEach(el => gb.prepend(svg.ownerDocument.importNode(el, true))); scenario.querySelectorAll('use.mapsheet').forEach(el => gb.querySelector('#background').after(svg.ownerDocument.importNode(el, true)));
if (startLocs) grid.before(svg.ownerDocument.importNode(startLocs, true)); if (startLocs) grid.before(svg.ownerDocument.importNode(startLocs, true));
const scenarioGrid = scenario.querySelector('.grid'); const scenarioGrid = scenario.querySelector('.grid');
@ -174,6 +174,12 @@ async function buildScenario(req) {
panzoom.start(svg); panzoom.start(svg);
gameboard.start(svg); gameboard.start(svg);
recordSheet.start(startLocs, gameboard.getUnits()); recordSheet.start(startLocs, gameboard.getUnits());
const mapContainer = document.querySelector('#map-container');
const mapContainerRect = mapContainer.getBoundingClientRect();
console.log('mapContainer', mapContainer);
console.log('mapContainerRect', mapContainerRect);
} }
function updateTurnCounter() { function updateTurnCounter() {

View File

@ -12,8 +12,13 @@ function restorePanZoomVal(svg) {
} }
function addEventListeners(svg) { function addEventListeners(svg) {
svg.addEventListener('wheel', e => zoom(svg, e, zoomFactor), { passive: false }); // svg.addEventListener('wheel', e => zoom(svg, e, zoomFactor), { passive: false });
svg.addEventListener('pointerdown', e => pan(svg, e), { passive: false }); // svg.addEventListener('pointerdown', e => pan(svg, e), { passive: false });
const group = svg.querySelector('.gameboard');
svg.addEventListener('wheel', e => zoom(group, e, zoomFactor), { passive: false });
svg.addEventListener('pointerdown', e => pan(svg, group, e), { passive: false });
} }
function storePanZoomVal(transformMatrix) { function storePanZoomVal(transformMatrix) {

View File

@ -194,6 +194,8 @@ export function start(startLoc, units) {
Observable.subscribe('select', select); Observable.subscribe('select', select);
Observable.subscribe('endmove', endMove); Observable.subscribe('endmove', endMove);
console.log('records created');
} }
export function stop() { export function stop() {