-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: `HTML` element bounding box calculation logic #1743 (#1744) Subtract the camera's transformation from the bounding box calculation logic of the `HTML` element to keep the result consistent with the native canvas element. * Version Packages (#1745) * chore(release): bump version * chore: update g-lite changelog --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: wang1212 <[email protected]> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7c68899
commit 103dcc7
Showing
97 changed files
with
660 additions
and
49 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,138 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width,user-scalable=no,initial-scale=1,shrink-to-fit=no" | ||
/> | ||
<title>Camera</title> | ||
<style> | ||
* { | ||
box-sizing: border-box; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
html, | ||
body { | ||
height: 100vh; | ||
} | ||
|
||
#container { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="container"></div> | ||
<script | ||
src="../packages/g/dist/index.umd.min.js" | ||
type="application/javascript" | ||
></script> | ||
<script | ||
src="../packages/g-canvas/dist/index.umd.min.js" | ||
type="application/javascript" | ||
></script> | ||
<script src="../packages/g-plugin-control/dist/index.umd.min.js"></script> | ||
<!-- <script src="../packages/g-svg/dist/index.umd.min.js" type="application/javascript"></script> | ||
<script src="../packages/g-webgl/dist/index.umd.min.js" type="application/javascript"></script> --> | ||
<script> | ||
console.log(window.G); | ||
const { Circle, CanvasEvent, Canvas, HTML } = window.G; | ||
|
||
// create a renderer | ||
const canvasRenderer = new window.G.Canvas2D.Renderer(); | ||
canvasRenderer.registerPlugin(new window.G.Control.Plugin()); | ||
|
||
// create a canvas | ||
const canvas = new Canvas({ | ||
container: 'container', | ||
width: 800, | ||
height: 800, | ||
renderer: canvasRenderer, | ||
}); | ||
|
||
const circle = new Circle({ | ||
style: { | ||
cx: 200, | ||
cy: 200, | ||
r: 50, | ||
fill: 'red', | ||
}, | ||
}); | ||
|
||
const html = new HTML({ | ||
style: { | ||
x: 150, | ||
y: 150, | ||
width: 100, | ||
height: 100, | ||
innerHTML: | ||
'<h1 style="width: 100px; height: 100px;">This is Title</h1>', | ||
}, | ||
}); | ||
|
||
canvas.addEventListener(CanvasEvent.READY, () => { | ||
canvas.appendChild(circle); | ||
canvas.appendChild(html); | ||
|
||
console.log('canvas.getCamera()', canvas.getCamera(), circle, html); | ||
console.log( | ||
'circle', | ||
'getBoundingClientRect', | ||
circle.getBoundingClientRect(), | ||
'getBounds', | ||
circle.getBounds(), | ||
); | ||
console.log( | ||
'html', | ||
'getBoundingClientRect', | ||
html.getBoundingClientRect(), | ||
'getBounds', | ||
html.getBounds(), | ||
); | ||
|
||
console.log('Camera pan(-50, 50) --------------------------'); | ||
canvas.getCamera().pan(-50, 50); | ||
requestAnimationFrame(() => { | ||
console.log( | ||
'circle', | ||
'getBoundingClientRect', | ||
circle.getBoundingClientRect(), | ||
'getBounds', | ||
circle.getBounds(), | ||
); | ||
console.log( | ||
'html', | ||
'getBoundingClientRect', | ||
html.getBoundingClientRect(), | ||
'getBounds', | ||
html.getBounds(), | ||
); | ||
|
||
console.log('Camera setZoom(1.2) --------------------------'); | ||
canvas.getCamera().setZoom(1.2); | ||
requestAnimationFrame(() => { | ||
console.log( | ||
'circle', | ||
'getBoundingClientRect', | ||
circle.getBoundingClientRect(), | ||
'getBounds', | ||
circle.getBounds(), | ||
); | ||
console.log( | ||
'html', | ||
'getBoundingClientRect', | ||
html.getBoundingClientRect(), | ||
'getBounds', | ||
html.getBounds(), | ||
); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
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
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
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
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
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
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
Oops, something went wrong.