Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider ruleWidth when zoom to fit #183

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

honorsin
Copy link
Contributor

finish TODO: consider padding from ruler

@F-star
Copy link
Owner

F-star commented Sep 26, 2024

可以解释一下代码的原理吗?

@honorsin
Copy link
Contributor Author

通过从视口尺寸中减去标尺宽度,calculateDimension函数可以准确确定可用于缩放和定位内容的实际空间,此调整可确保缩放的内容正确适合画布的可见区域。

在计算新视口位置时,将rulerWidth添加回来并除以newzoom,来补回之前由于计算实际空间减去的标尺宽度,而产生的向下和向又的偏移量,确保内容相对于整个视口(包括标尺区域)正确居中。

我已经测试了不同rulerWidth和屏幕宽度的计算情况,测试了其可以正确布局。

@honorsin
Copy link
Contributor Author

通过从视口尺寸中减去标尺宽度,calculateDimension函数可以准确确定可用于缩放和定位内容的实际空间,此调整可确保缩放的内容正确适合画布的可见区域。

在计算新视口位置时,将rulerWidth添加回来并除以newzoom,来补回之前由于计算实际空间减去的标尺宽度,而产生的向下和向又的偏移量,确保内容相对于整个视口(包括标尺区域)正确居中。

我已经测试了不同rulerWidth和屏幕宽度的计算情况,测试了其可以正确布局。

其实也就是先计算了把rulerWidth减去时候的视口空间时的布局, 然后根据rulerWidth/newZoom把这些损失的偏移又补回来

@F-star
Copy link
Owner

F-star commented Sep 26, 2024

ok

@F-star F-star merged commit 138481f into F-star:main Sep 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants