Zoom the tile tab in the same steps as the scene view
The tile tab zoomed freely, so the pixels of a tile could end up
unevenly wide at odd factors. Scene view, container tab and animation
preview already snap to FREE_ZOOM_STEPS. The tile tab now does the
same, so every pixel editor zooms alike.
- The wheel steps through FREE_ZOOM_STEPS, counted in device pixels.
The board position is rounded to whole device pixels.
- New wheelSteps() in src/viewport/view.ts turns wheel events into
steps: one notch is one step, a trackpad gathers 50 px per step.
FreeViewport uses it too, so the rule exists only once.
- Fit takes the largest step at which the whole board fits. Refitting
on a new tab or board size stays as before.
- panAndZoom takes an optional zoom rule instead of limits. Graph and
node board keep zooming freely.
- A saved view from before the steps snaps to the nearest step.
- The cap parameter of frameBoxes from 4027afc has no user anymore.
It is removed together with its unit test.
Fit rounds down, and below 100 percent the steps are far apart. In the
small e2e window the 48 px board lands at 25 instead of 41 percent,
the 16 px board at 100 instead of 124 percent.
Tests:
- check.sh: 161 files, 2370 tests, exit 0 (-1 cap test,
+1 wheelSteps test)
- e2e 1-5 and 39: all passed, 169 checks. Three checks in 39 now
expect steps: Fit on a step with the next one too large, one notch
goes 0.25 to 0.5, 16 px tiles refit to at least 100 percent.
- Counter check: a free Fit factor fails exactly those three checks
(zoom 0.413 and 1.2396).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4027afc228
commit
021a6dcb56
8 files changed
+110
-47
No files matched your search
@@ -141,13 +141,6 @@ describe('fit', () => {
|
||||
expect(f.zoom).toBe(1);
|
||||
});
|
||||
|
||||
it('fills the view up to a raised cap – the Tile tab, whose board is a few tiles of 16 px', () => {
|
||||
const board: Box[] = [{ id: 'board', x: 0, y: 0, w: 345, h: 186 }];
|
||||
const f = frameBoxes(board, { w: 1000, h: 600 }, 16, { min: 0.1, max: 6 }, 6);
|
||||
expect(f.zoom).toBeCloseTo((1000 - 32) / 345);
|
||||
expect(frameBoxes(board, { w: 10000, h: 6000 }, 16, { min: 0.1, max: 6 }, 6).zoom).toBe(6);
|
||||
});
|
||||
|
||||
it('never zooms out past the limit, however far the nodes are apart', () => {
|
||||
const far: Box[] = [
|
||||
{ id: 'a', x: 0, y: 0, w: 100, h: 60 },
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
nearestZoomStep,
|
||||
screenToWorld,
|
||||
stepFreeZoom,
|
||||
wheelSteps,
|
||||
worldBounds,
|
||||
worldToScreen,
|
||||
zoomStepBelow,
|
||||
@@ -71,6 +72,17 @@ describe('free view zoom steps under Windows scaling', () => {
|
||||
expect(nearestZoomStep(1.37)).toBe(1);
|
||||
expect(nearestZoomStep(0.4)).toBe(0.5);
|
||||
});
|
||||
|
||||
it('a mouse notch is a step, a trackpad gathers travel, and turning drops what was left', () => {
|
||||
const wheel = wheelSteps();
|
||||
expect(wheel(-100)).toBe(1);
|
||||
expect(wheel(100)).toBe(-1);
|
||||
expect([wheel(-20), wheel(-20), wheel(-20)]).toEqual([0, 0, 1]);
|
||||
expect(wheel(-40)).toBe(0);
|
||||
// The 40 up still pending are dropped: 40 down alone are no step yet, 60 are.
|
||||
expect(wheel(40)).toBe(0);
|
||||
expect(wheel(20)).toBe(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('cameraView', () => {
|
||||
|
||||
Reference in new issue
Block a user