-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a strictBounds flag (#404)
Enabling strictBounds will not render / process nodes that are outside of the visible area, otherwise the default behavior will render all nodes regardless of their boundary status.
- Loading branch information
Showing
7 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import type { ExampleSettings } from '../common/ExampleSettings.js'; | ||
|
||
export async function automation(settings: ExampleSettings) { | ||
const page = await test(settings); | ||
page(1); | ||
await settings.snapshot(); | ||
|
||
page(2); | ||
await settings.snapshot(); | ||
|
||
page(3); | ||
await settings.snapshot(); | ||
} | ||
|
||
export default async function test({ renderer, testRoot }: ExampleSettings) { | ||
// Create a container node | ||
const containerNode = renderer.createNode({ | ||
x: 10, | ||
y: 100, | ||
width: 1000, | ||
height: 600, | ||
color: 0xff0000ff, // Red | ||
parent: testRoot, | ||
}); | ||
|
||
const status = renderer.createTextNode({ | ||
text: 'Strict Bound: ', | ||
fontSize: 30, | ||
x: 10, | ||
y: 50, | ||
parent: testRoot, | ||
}); | ||
|
||
const amountOfNodes = 11; | ||
const childNodeWidth = 1700 / amountOfNodes; | ||
|
||
// Create 11 child nodes | ||
for (let i = 0; i < amountOfNodes; i++) { | ||
const childNode = renderer.createNode({ | ||
x: i * childNodeWidth + i * 100, | ||
y: 100, | ||
width: childNodeWidth, | ||
height: 300, | ||
color: 0x00ff00ff, // Green | ||
parent: containerNode, | ||
}); | ||
|
||
const nodeTest = renderer.createTextNode({ | ||
x: 10, | ||
y: 130, | ||
text: `Node ${i}`, | ||
color: 0x000000ff, | ||
parent: childNode, | ||
}); | ||
} | ||
|
||
renderer.on('idle', () => { | ||
status.text = 'Strict Bound: ' + String(containerNode.strictBounds); | ||
}); | ||
|
||
window.onkeydown = (e) => { | ||
if (e.key === 'ArrowRight') { | ||
containerNode.x -= 100; | ||
} | ||
|
||
if (e.key === 'ArrowLeft') { | ||
containerNode.x += 100; | ||
} | ||
|
||
if (e.key === ' ') { | ||
containerNode.strictBounds = !containerNode.strictBounds; | ||
} | ||
}; | ||
|
||
const page = (i = 0) => { | ||
switch (i) { | ||
case 1: | ||
containerNode.x = -590; | ||
break; | ||
|
||
case 2: | ||
containerNode.x = -1390; | ||
break; | ||
|
||
case 3: | ||
containerNode.strictBounds = true; | ||
break; | ||
} | ||
}; | ||
|
||
return page; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+13.1 KB
visual-regression/certified-snapshots/chromium-ci/viewport-strictbounds-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.2 KB
visual-regression/certified-snapshots/chromium-ci/viewport-strictbounds-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.95 KB
visual-regression/certified-snapshots/chromium-ci/viewport-strictbounds-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.