Repository navigation
缩放画布之后,如何保存画布的位置,重绘时回到原本的位置 #7529
Unanswered
WebGeniusLT
asked this question in
Q&A
Replies: 1 comment
|
原因是
按源码推导(未在浏览器中实测), 还原时不要用 // 保存
const saved = { zoom: graph.getZoom(), position: graph.getPosition() };
// 重绘之后(在 await graph.render() 之后执行)
await graph.zoomTo(saved.zoom, false);
const [x, y] = graph.getPosition();
await graph.translateBy([saved.position[0] - x, saved.position[1] - y], false);另外请确认重绘时没有开启 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
当前使用的g6版本未5.0.49,当缩放了画布,并且拖动画布之后,通过2个方法保留了缩放比例(graph.getZoom())和画布的位置(graph.getPosition()),重绘时使用了await graph.zoomTo(zoom); graph.translanteTo([x, y]); 但没有恢复到保存时的位置,并且偏差比较大
All reactions